Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:06:57+00:00 2026-06-08T10:06:57+00:00

I have an image upload script that allows simple PHP upload of profile pictures.

  • 0

I have an image upload script that allows simple PHP upload of profile pictures. It is now unexpectedly failing on upload. I am not entirely sure why. I have checked the post_max_size and the upload_max_size and they are way over 1MB. I have a suspicion it is to do with the //Delete previous picture but not sure why. If you look at the query where it says;

AND image1 !='../files/noprofile.jpg'

This is so that if the profile picture is the default the image for the default is not deleted. I have a feeling it is to do with this part and the upload fails when the image IS the default profile picture.

I know i should be using mysqli but please don’t mention that i am working on it.

Here’s the entire script with a few thing taken out for simplicity purposes:

session_start();
$username=$_SESSION['username'];
$pass = $_SESSION['password']; 
$path = "../imageuploads/";

//Delete previous picture
$pic = mysql_query("
SELECT * FROM members WHERE artist='Y' AND username='$username' AND password='$pass' AND image1 !='../files/noprofile.jpg'
")or die(mysql_error());

 while($fetchpic = mysql_fetch_array($pic)){ 

//if image1 does not equal no profile
unlink( $fetchpic['image1']); 

}


$valid_formats = array("jpg", "png", "gif", "bmp", "jpeg");
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
    {
        $name = $_FILES['photoimg1']['name'];
        $size = $_FILES['photoimg1']['size'];

        if(strlen($name))
            {
                list($txt, $ext) = explode(".", $name);
                if(in_array($ext,$valid_formats))
                {
                if($size<(2024*2024))
                    {
                        $actual_image_name = time().substr(str_replace(" ", "_", $txt), 5).".".$ext;
                        $tmp = $_FILES['photoimg1']['tmp_name'];
                        if(move_uploaded_file($tmp, $path.$actual_image_name))
                            {
                            mysql_query("UPDATE members SET image1='../imageuploads/$actual_image_name' WHERE username='$username' AND password ='$pass' AND artist='Y'");

                                echo "<p1><img src='../imageuploads/".$actual_image_name."'  class='imageright1'></p1>";
                            }
                        else
                            echo "<p1>failed</p1>";
                    }
                    else
                    echo "<p1>Your image is a bit too big. It has to be below 1MB.</p1>";                   
                    }
                    else
                    echo "<p1>Only JPG, PNG GIF and BMP file formats are accepted.</p1>";   
            }

        else
            echo "<p1>You've gotta select an image first!</p1>";

        exit;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:06:58+00:00Added an answer on June 8, 2026 at 10:06 am

    In your form tag, add the attribute enctype:

    <form action="page.php" method="post" enctype="multipart/form-data">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small php script which allows me to upload image file on
I have a file (image) upload script in PHP that I use to upload
I have a script that allows a user to upload an image to Google
I have a small python cgi script that accepts an image upload from the
I have an image upload script, and the thumbnails that its producing are posterized
i have this image upload script. <?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $imagename = $_FILES['new_image']['name'];
I have an image upload script that batch uploads loads of images. I want
A thought experiment: You have a CMS that allows users to upload an image,
I am looking for a really simple PHP image gallery system that allows file
I have a script that uploads an image using JavaScript, as seen here .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.