Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 7th, 2003, 10:49 PM
Registered User
Join Date: Jun 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default php file upload


I'm trying to use the script below to upload files to my server. I can't get it to work. I'm running PHP 4.3.2 on a Linux server. When I browse for the file and hit the send button it looks like it's working but the file isn't anywhere to be found on the server. I checked the temp directory and the directory it's supposed to copy to. Anyone have any ideas as to why this isn't working?



<title>Listing 9.14 A file upload script</title>
$file_dir = "/home/corrdev/htdocs/php24/scrap/uploads";
$file_url = "http://corros.colo.hosteurope.com/dev/php24/scrap/uploads";

foreach( $HTTP_POST_FILES as $file_name => $file_array ) {
    print "path: ".$file_array['tmp_name']."<br>\n";
    print "name: ".$file_array['name']."<br>\n";
    print "type: ".$file_array['type']."<br>\n";
    print "size: ".$file_array['size']."<br>\n";

    if ( is_uploaded_file( $file_array['tmp_name'] )
        && $file_array['type'] == "image/gif" ) {
        move_uploaded_file( $file_array['tmp_name'], "$file_dir/$file_name")
            or die ("Couldn't copy");
        print "<img src=\"$file_url/$file_name\"><p>\n\n";

<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
<input type="file" name="fupload"><br>
<input type="submit" value="Send file!">

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to upload mp3 file using php abhi.sharma05 PHP How-To 4 November 1st, 2011 11:59 PM
Whole Folder upload(Multi file Upload) ramasamy_rams XML 1 September 9th, 2005 12:43 PM
upload a simple .php file scrowler Beginning PHP 3 November 15th, 2004 10:54 PM
File upload problems in PHP 4.3.2 clem_c_rock Pro PHP 2 November 1st, 2004 10:49 AM
PHP file upload qazi_nomi PHP How-To 2 July 11th, 2004 10:43 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.