SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Jan 2007
    Posts
    934
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    testing file uploading

    On a multi-user site, I've gotten feedback that some users have been having trouble uploading their profile images on one form, and documents on another. However, I haven't been able to get specific information on the errors received. Can you all come up with a checklist of things to test? I can't find any errors.

    Many thanks E

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    This kind of thing is quite tricky to test.
    What I generally do, when something that works for some people and not for others, is to email a var_dump($_FILES) whenever something is uploaded. That should contain the error code for the upload, which may give some more information. (alternatively, you could write the var_dump() to a text file and check it every now and then).

    From there, you could try to find out why the upload is failing for some users.

    Are you using a Flash uploader or a standard file input?

  3. #3
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,904
    Mentioned
    93 Post(s)
    Tagged
    0 Thread(s)
    Have you tried something like this:

    PHP Code:
    <?php 

    function file_upload_error_message($error_code) {
        switch (
    $error_code) { 
            case 
    UPLOAD_ERR_INI_SIZE
                return 
    'The uploaded file exceeds the upload_max_filesize directive in php.ini'
            case 
    UPLOAD_ERR_FORM_SIZE
                return 
    'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'
            case 
    UPLOAD_ERR_PARTIAL
                return 
    'The uploaded file was only partially uploaded'
            case 
    UPLOAD_ERR_NO_FILE
                return 
    'No file was uploaded'
            case 
    UPLOAD_ERR_NO_TMP_DIR
                return 
    'Missing a temporary folder'
            case 
    UPLOAD_ERR_CANT_WRITE
                return 
    'Failed to write file to disk'
            case 
    UPLOAD_ERR_EXTENSION
                return 
    'File upload stopped by extension'
            default: 
                return 
    'Unknown upload error'
        } 


    // Example
    if ($_FILES['file']['error'] === UPLOAD_ERR_OK)
        
    // upload ok
    else
        
    $error_message file_upload_error_message($_FILES['file']['error']); 

    ?>
    (example above came from http://uk.php.net/manual/en/features...oad.errors.php about the sixth comment down)

    $error_message would be passed along to your error and/or exception handler.

    Have you checked php error log for any errors around the time the problem with uploads occurs?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  4. #4
    SitePoint Guru
    Join Date
    Jan 2007
    Posts
    934
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you, these comments are very helpful. Its a plain html uploader. They need javascript to work. That could be part of the issue. Javascript could be blocked on some computers.

    SpacePhoenix I definitely have some of those validation catches but I'll check to see if I have all of them. That's a good list.

    Thank You E

  5. #5
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,904
    Mentioned
    93 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by eruna View Post
    Thank you, these comments are very helpful. Its a plain html uploader. They need javascript to work. That could be part of the issue. Javascript could be blocked on some computers.

    SpacePhoenix I definitely have some of those validation catches but I'll check to see if I have all of them. That's a good list.

    Thank You E
    The blocking of javascript could well be the problem, ask the users concerned if they have javascript blocked.
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator


Bookmarks

Posting Permissions

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