PHP also supports the function of uploading files, but not all websites that support PHP support this feature, especially free websites.
Implement it uploaded, first join the "
When you upload with PHP, you need to check the content, such as whether you allow reading and write files, file formats, and file size in the size you specify.
$ File_size_max = 1000000; // Limit file Upload Maximum Capacity (Bytes) $ store_dir = "/ public / www / upload /"; // Upload file storage location $ accept_overwrite = true; // Allow read and write files // Check file size if ($ upload_file_size> $ file_size_max) {echo "Sorry, your file capacity is greater than the specified"; exit;} // check the read and write file IF (file_exists ($ store_dir. $ Upload_file_name) &&&&! $ Accept_overwrite {echo "File already exists, no replication"; exit;} // copy file to the specified directory IF (! @ Copy ($ upload_file, $ store_dir. $ Upload_file_name)) {Echo "copy file failed"; EXIT;} Echo "upload Document completion ";?>
It should be noted that PHP is copied to the server temporary directory (TEMP) when the file is uploaded, and then use the PHP "Copy ()" function to copy the file from the temporary directory to the stored directory you specified. Since the program uses a temporary directory to work, if the server blocks the above features due to security issues, you cannot use the PHP upload function.
In addition, the uploaded file directory also needs to set file mode 777 (ChMOD 777), otherwise PHP does not have to read and write files.