How to solve a simple file upload error _ PHP Tutorial

Source: Internet
Author: User
An error occurred while uploading files. I haven't paid much attention to file upload before. I made a simple task yesterday, but I found many problems. The initial program code is as follows: uploadimg. php (as the current mainstream development language) has not paid much attention to file upload before. yesterday I made a simple one but found many problems.

The initial program code is as follows:
Uploadimg. php (as the mainstream development language)

// Determine whether the upload interface is an implementation interface. if the upload interface is used, the following HTML page is displayed.
If (! $ _ POST [UploadAction]):

?>








// If it is an implementation page, the following HTML page is displayed, and the php (as the mainstream development language) script is activated
Else:

?>






// Www.knowsky.com initializes the UploadAction status
$ UploadAction = 0;

$ UploadFile =$ _ POST [UploadFile];

If ($ UploadFile! = "None") & ($ UploadFile! = ""))
{
$ UploadPath = $ _ SERVER [DOCUMENT_ROOT]. "\";

If (! Is_writeable ($ UploadPath ))
{
Echo "$ UploadPath directory cannot be written! "; Exit;
}
Else
{
Echo "$ UploadPath directory writable! ";
}

$ FileName = $ UploadFile_name;

If ($ UploadFile_size <1024)
{
$ FileSize = (string) $ UploadFile_size. "byte ";
}
Elseif ($ UploadFile_size <(1024*1024 ))
{
$ FileSize = number_format (double) ($ UploadFile_size/1024), 1). "KB ";
}
Else
{
$ FileSize = number_format (double) ($ UploadFile_size/(1024*1024), 1). "KB ";
}
If (! File_exists ($ UploadPath. $ FileName ))
{
If (move_uploaded_file ($ UploadFile, $ UploadPath. $ FileName ))

Bytes. The initial program code is as follows: uploadimg. php (as the mainstream development language )...

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.