Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php upload not working

    I know you've probably had this question asked multiple times, but I searched through the post and found nothing that helped.

    I can't get a file to upload using php. I get no errors, just the file doesn't appear. I'm using Apache 1.3.26, PHP 4.2.2 on Windows 2000 Server. I've used other file system scripts such as read/write, dir listing. Here's the file upload part of my php.ini and the upload script. Thanks in advance.

    php.ini :

    ;;;;;;;;;;;;;;;;
    ; File Uploads ;
    ;;;;;;;;;;;;;;;;

    ; Whether to allow HTTP file uploads.
    file_uploads = On

    ; Temporary directory for HTTP uploaded files (will use system default if not
    ; specified).
    upload_tmp_dir = C:\Fireserv\www\uploads

    ; Maximum allowed size for uploaded files.
    upload_max_filesize = 2M

    upload.php :

    <form enctype="multipart/form-data" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="3000000000000">
    Send this file: <input name="userfile" type="file">
    <input type="submit" value="Send File">
    </form>

  • #2
    New Coder
    Join Date
    Feb 2003
    Location
    Rannana,(o) IsraeL (o)
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is display_errors=on ?
    and does folder "C:\Fireserv\www\uploads" exist?
    Perhaps the problem is at code.
    Submit your code :}

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Display errors is on and the directory des exist. I copied it from the windows address bar.

    (Display full pathname in address bar is enabled)

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    If that's all your php code for the upload, then I doubt it would work. You need to add upload directory paths etc into a script

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what variant are you using to access the file properties once it is uploaded? Showing the rest of your script would have helped a tad here...

    $_FILE['userfile']['tmp_name'] ?
    $userfile_type ?
    $HTTP_POST_FILES['userfile']['name'] ?
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It works now. My problem is that when I browsed the tmp directory, there was nothing there. But now it seems to be fine.

    Here's my code.

    PHP Code:
    <html>
    <?php
    $file_dir 
    "c:\fireserv\www\uploads";
    $file_url "http://localhost/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'] ) ) {
            
    move_uploaded_file$file_array['tmp_name'], "$file_dir/$file_name")
                or die (
    "Couldn't copy");
            print 
    "<a href=\"$file_url/$file_name\">$file_name</a>\n\n";
        }
    }
    ?>
    <body>
    <form enctype="multipart/form-data" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="3000000000000">
    <input name="fupload" type="file"><br>
    <input type="submit" value="Send File">
    </form>
    </body>
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •