move upload confusion
Posted: Thu Dec 17, 2009 9:16 am
Hello,
It may be silly. Is that possible. Trying to upload one file(image file) from the form to a directory with different name.
When try to upload by removing the "below two line" it work usual but when i try to add this two line to upload that file with different name. One is the $_FILES["FileToUpload"]["name"] and the other is the $thumb.
Adding these two line doesn't effect the script. The script create filename with the first one($NewName).
Is this a overwriting issue or it doesn't work because it move_uploaded_file(I mean try to cut from php temporary to the destination.) That's why those two line has no effect in the script??????????
Any suggestion?
thank you ALL.
It may be silly. Is that possible. Trying to upload one file(image file) from the form to a directory with different name.
Code: Select all
$CurrentPath="./upload";
$_POST["ActionIfFileExistsOnUpload"]="Make unique";
if(isset($_FILES["FileToUpload"])&&$_FILES["FileToUpload"]["name"]!="")
{
$NewName = $_FILES["FileToUpload"]["name"];
if(file_exists("$CurrentPath/{$_FILES["FileToUpload"]"name"]}")&&$_POST["ActionIfFileExistsOnUpload"]=="Make unique")/*ignore that one it's just try to be a unique*/
{
$NewName = md5(uniqid(rand(0, 1000),1))."_".$_FILES["FileToUpload"]["name"];
$thumb = md5(uniqid(rand(0, 1000),1))."thumb_".$_FILES["FileToUpload"]["name"];
}
move_uploaded_file($_FILES["FileToUpload"]["tmp_name"], "$CurrentPath/$NewName");
$thumb = "thumb_".$_FILES["FileToUpload"]["name"];/*try to rename*/
move_uploaded_file($_FILES["FileToUpload"]["tmp_name"], "$CurrentPath/$thumb"); /possible????????/
}Code: Select all
$thumb = "thumb_".$_FILES["FileToUpload"]["name"];
move_uploaded_file($_FILES["FileToUpload"]["tmp_name"], "$CurrentPath/$thumb");Is this a overwriting issue or it doesn't work because it move_uploaded_file(I mean try to cut from php temporary to the destination.) That's why those two line has no effect in the script??????????
Any suggestion?
thank you ALL.