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.