Can I ask why you're creating a new folder for each image? It seems a bit over the top to me. Also it seems that the image is being saved without a file extension.
For example if you upload image123.png, it gets stored to:
http://www.websitename.com/members/uploaded/1328/20100528100957.image123
The db record shows: id = 1328, img1 = http://www.websitename.com/members/uploaded/1328/20100528100957.image123
THis looks like a really complicated was of storing images.
However, this should work:
if($lastid > 0)
{
$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/$lastid";
mkdir("uploaded/$lastid", 0755);
$dest = $dest."/".$image_name;
$val = move_uploaded_file($_FILES['profile_image']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . "/$dest"); //upload image to the destination path
if($val){
mysql_query("update memberst set img1='http://www.websitename.com/members/$dest where id=$lastid");
}
Are you allowing different file formats, like png, gif, jpg, svg? If so, how will your site know which type to serve when an image needs to be shown?
diafol
Rhod Gilbert Fan (ardav)
Moderator
7,800 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080