How do I implement file uploads?
The following are the referenced contents: <HTML> <HEAD> <TITLE> File Upload Interface </TITLE> </HEAD> <BODY><TABLE><CENTER> ? if ($UploadAction) { $UploadAction = 0; $TimeLimit = 60; /* Set timeout limit time is 30s, set to 0 when unlimited * * Set_time_limit ($TimeLimit); If (($Upfile!= "None") && ($Upfile!= "")) { $Filepath = "D:\web\web\php\test"; Upload File Store path $FileName = $Filepath. $Upfile _name; if ($Upfile _size <1024)//upload file size {$FileSize = (string) $Upfile _size. "Bytes";} ElseIf ($Upfile _size < (1024 * 1024)) { $FileSize = Number_format (double) ($Upfile _size/1024), 1). "KB"; } Else { $FileSize = Number_format (double) ($Upfile _size/(1024*1024)), 1. " MB "; } if (!file_exists ($FileName)) { if (copy ($Upfile, $FileName)) {unlink ($Upfile); echo "<br><br>\n"; echo "File $Upfile _name has been uploaded successfully! "; echo "<br><br>\n"; echo "File location: $FileName"; echo "<br><br>\n"; echo "File size: $FileSize"; echo "<br><br>\n"; } Else {echo ' file $Upfile _name upload failed! "; } } Else {echo ' file $Upfile _name already exists! "; } } Else {echo "You didn't choose any file upload!" "; } Set_time_limit (30); Restore default timeout settings } ?> <form enctype = "Multipart/form-data" NAME = "SubmitForm" ACTION = "default.php" method = "POST" > <input TYPE = "hidden" NAME = "max_file_size" VALUE = "1000000" > <input TYPE = "hidden" NAME = "uploadaction" VALUE = "1" > <tr><td><input NAME = "Upfile" TYPE = "file" SIZE = "></TD>" </tr><tr><td><input NAME = "submit" VALUE = "submit" TYPE = "Submit" > <input NAME = "reset" VALUE = "reset" TYPE = "Reset" ></TD> </TR></FORM></CENTER></TABLE> </BODY> </HTML> |