I'd like to set a custom filename (just take the filename and append the date/time then SHA1 that) for files I upload. I can't seem to find any docs on how to achieve this. Anyone know?
In my scripts I use the following to make sure the file is saved to disk before modifying it. Hope the example helps.
$newfile = "location/name.ext"; //Save copy to
$copy = copy($_FILES[$upload_name]['tmp_name'],$newfile);
if ($copy){ //If the file uploaded and copied
//Perform functions such as Resizing, Add to Database, ect...
//If you want to modify the name after performing functions...
rename("old-location/name.ext", "new-location/name.ext");
}
move_uploaded_file
I assume you are using PHP, if not you are on your own.
See http://us.php.net/move_uploaded_file which describes how to save uploaded files in PHP.
This is kind of out of the scope of SWFUpload. Once the file successfully makes it to your server its up to you what you do with it.
But mostly you just need to build your Path and File name and pass it into move_uploaded_file as the $destination parameter.
copy
In my scripts I use the following to make sure the file is saved to disk before modifying it. Hope the example helps.
$newfile = "location/name.ext"; //Save copy to
$copy = copy($_FILES[$upload_name]['tmp_name'],$newfile);
if ($copy){ //If the file uploaded and copied
//Perform functions such as Resizing, Add to Database, ect...
//If you want to modify the name after performing functions...
rename("old-location/name.ext", "new-location/name.ext");
}