PHP Example: Implementation of File upload program source code

Source: Internet
Author: User
Tags file size file upload php example reset

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>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.