Hi all

I have the following script 99.9% working for uploading a single image to a database -
Storing the file in a folder and placing a link to the file in the database -

The only problem im having now is when the image is uploaded the extension of the image is removed

the file is stored as imagename. (but I need to store the image correctly)

Is there anyone here that can help me with this please.

here is the code im using

$qry = "INSERT INTO mgallery(id,uid,mpicture,title,date) VALUES('','$id','$image_name','$title',now())";
            $result = @mysql_query($qry);
$image_ext = explode('.', $image);  //split the image name with respect of " . "
$image_name = date('Ymdhis'). "." . $image_ext[1];  //create unique image name with present "date & time"

            $dest = "uploaded/$id";
            $dest = $dest."/".$image_name;   
move_uploaded_file($_FILES['profile_image']['tmp_name'], $dest); //upload image to the destination path
      		mysql_query("update mgallery set mpicture ='http://www.website.com/members/$dest'"); //WORKING IMAGE UPLOAD 
				echo "Success";
			exit ();
            die("Upload failed");
7 Years
Discussion Span
Last Post by chrishea

Is image the full URL or just the actual filename portion? If I was in your position, I would echo the values of $image and and $image_ext[0] and $image_ext[1] after line 5 to get more info about what is going on.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.