Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'tmp_name'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. I believe there is an error in the book regarding uploads and the temporary file created when performing uploads. Regarding uploads, Larry writes in Chapter 11: "If the file was uploaded but it could not be moved to its final destination or some other error occurred, then that file is still sitting on the server in its temporary location." However, the PHP manual states: "The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed." Source: https://secure.php.net/manual/en/features.file-upload.post-method.php In studying the upload process, I removed the code in upload_image.php that calls move_uploaded_file() and just dumped the upload info to confirm that the request went through without errors. I searched my entire system for the file (starting with the location I set in upload_tmp_dir of course, and confirming that all users had write access to the folder) but it was not found, proving that the file is removed at the end of the request. When I added the code back to move the file to a permanent location via move_uploaded_file, the file was moved to the permanent location as expected. So it seems that move_uploaded_file() is *required* to be used when uploading a file if you want to save whatever was uploaded. I am running PHP 7.1.7 via XAMPP on Windows 10 and got the same results on Chrome and Firefox. A modified upload_image.php script is below that you can run yourself. Let me know if anyone gets a different result or I am incorrect in what I wrote above. Thanks! <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Upload an Image</title> </head> <body> <?php // Check if the form has been submitted: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Check for an uploaded file: if (isset($_FILES['upload'])) { echo "<pre>"; var_dump($_FILES); echo "</pre>"; } } // End of the submitted conditional. ?> <form enctype="multipart/form-data" action="upload_image.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="128000000"> <fieldset> <p><strong>File:</strong> <input type="file" name="upload"></p> </fieldset> <div align="center"><input type="submit" name="submit" value="Submit"></div> </form> </body> </html>
×
×
  • Create New...