Hi.
Can someone help me change the name of an uploaded image?
I've tried almost everything. I know I'm new to this, but I'm awful frustrated. I have the login/logout functions working, mysql inserts, and other things working, but I've been working on this all day (and yes, I even read the manual followed by hours of googling) but I just don't get it.
Here's the code:
//upload image
$target = "estickerimages/";
$ok=1;
//check size
if ($uploaded_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}
//create file extension in variable $imagetype
if ($uploaded_type =="image/jpg")
{
$imagetype=".jpg";
}
if ($uploaded_type =="image/jpeg")
{
$imagetype=".jpeg";
}
if ($uploaded_type =="image/bmp")
{
$imagetype=".bmp";
}
if ($uploaded_type =="image/gif")
{
$imagetype=".gif";
}
if ($uploaded_type =="image/png")
{
$imagetype=".png";
}
if (empty($imagetype))
echo "That file type is not allowed.<br>";
//check that $ok was not set to 0
if ($ok==0)
{
echo "Sorry. Your file was not uploaded.";
}
//If everything is ok try to upload it
else
{
$target = $target . basename( $_FILES['uploaded']['name']) ;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "Your image was uploaded.";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
//end upload image
I have tried using the pathinfo function, echoing variables, etc, but I can't seem to change the name and have it save properly. Where is the saving of the file done? In "move_uploaded_file"?