PHP file upload implementation

xiaoxiao2021-03-06  90

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 "

" table of the upload file on HTML.

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) {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.

转载请注明原文地址:https://www.9cbs.com/read-105886.html

New Post(0)