Tuesday, August 3, 2010

Example PHP File Upload Script

Example PHP File Upload Script

Below shows a PHP file upload script that is written to handle the form data submitted from the earlier XHTML MP document. The PHP script prints out the information obtained from the HTTP request and saves the uploaded file to the "/file_uploads" directory of the WAP server.


Code:
'; ?>



**
****
**

**
****

Data Received at the Server

****
**** $value){ ?> Name-value Pair Info: Field name: Field value: Uploaded File Info: Content type: Field name: myFile File name: File size: 0){ ****if ($optionalFileName == "") ******$fileName = basename($fileName); ****else ******$fileName = $optionalFileName; ****$dirName = '/file_uploads/'; ****if (move_uploaded_file($_FILES['myFile']['tmp_name'], $dirName . $fileName)){ ?> The uploaded file has been saved successfully. An error occurred when we tried to save the uploaded file. **** **

No comments:

Post a Comment