Hi,
I put some adds features on your script.
My english is not good enough to make you
a tutorial so..
*************form.html************
<form enctype="multipart/form-data" action="upload.php">
<input type="file" name="internal_form">
<input type="hidden" name="MAX_FILE_SIZE" value="250000">
<input type="submit>
</form>
**********form end****************
(The INPUT hidden "MAX_FILE_SIZE" is strongly recommended
to not let the users to doesn't put big file.
The value is in Octet, you can optimize it for you needs.)
************upload.php***************
//Upload script
//--Take the filename uploaded without the PhP Temp Folder----//
$FileDst=$internal_form_name;
//--Separate the name and the extension----//
$FileCutted = explode(".", $FileDst);
//-----Here You can add testing of the extension ( $FileCutted[1]=="gif",etc... )------//
if(isset($internal_form) && !empty($internal_form))
{
//----Make a unique filename with a Date----//
$FileDst=date("dmyHis").".".$FileCutted[1];
//----Mix the directory upload path with the new filename-----//
$new_file= c:\folder.'/'.$FileDst;
copy($internal_form, $new_file);
}
***********uplaod end*****************
hope is good for you,
@+
chris wrote:
How does one copy a file and maintain the file extension?
Example
I have a form where people will need to upload .xcl, .doc, .ppt files for an intranet application
My problem is when I copy the file like this
*************form.html************
<form enctype="multipart/form-data" action="upload.php">
<input type="file" name="internal_form">
<input type="submit>
</form>
**********form end****************
************upload.php************
//Upload script
if(isset($internal_form) && !empty($internal_form))
{
$new_file= c:\folder.'/'.date("ydms");
copy($internal_form, $new_file);
}
********uplaod end*****************
So when I look at the uploaded file there is no extension for the file, how do I maintain the extension?
Thanks