Hi all,
can someone help me here -
I ave a regisration script where I am uploading an image to mysql,
The problem im having at the moment is this.....
The script creates a new folder by using the mysql_last_id function as shown below -
The problem im having is concatinating the image path to be the document root.
ie. websitename.com/members/uploaded/12/image.jpg
i have tried using $_server document root again as below shows, but the directory is not being created with server document root.
document root option - directory being created as $lastid not id number of 12
$lastid = mysql_insert_id ();
//Check whether the query was successful or not
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 = ($_SERVER['DOCUMENT_ROOT'].'/members/uploaded/$lastid');
mkdir ($_SERVER['DOCUMENT_ROOT'].'/members/uploaded/$lastid', 0755);
$dest = $dest."/".$image_name;
$val = move_uploaded_file($_FILES['profile_image']['tmp_name'], $dest); //upload image
to the destination path
if($val){
mysql_query("update memberst set img1='$dest' where id=$lastid");
}
concatination option - no image being uploaded
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'], $dest); //upload image to the destination path
if($val){
mysql_query("update memberst set img1='http://www.websitename.com/members/$dest where id=$lastid");
}
im not sure what is the best option to get both directory created and image path uploaded to the database.
hope someone can point me in the right direction.