SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast Hanabi's Avatar
    Join Date
    Mar 2002
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Picture uploads sometimes fail!

    Hi all,
    I try to upload files to my webspace. It only works with some of them. The following code returns the temporary name of the file but when it fails It displays 'none'.

    PHP Code:
     echo( "<br>" $_FILES['image']['tmp_name'] );
    //save to pics directory
    @copy$_FILES['image']['tmp_name'], "pics/" $_FILES['image']['name'] ); 
    Can anyone tell me why this happens? and how could I solve this problem
    Thanks for your time.

    Hanabi.

  2. #2
    SitePoint Addict whofarted's Avatar
    Join Date
    Aug 2001
    Location
    lost, If you find me please return me to St.Louis
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would say remove the @ in front of copy & see if you get an error.

    Also, Is it not working with certain extentions or is it seamingly random?
    You smell something?

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    Ljubljana, Slovenia
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    check the POST size .. and max upload size in PHP ini !

  4. #4
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    also try the new

    $_FILES['image']['error']

    this will return an numeric upon upload error which *should* help indicate exactly what went wrong.

    I wrote this multiple ternery for a dual image upload which you could easily adapt

    PHP Code:
    if($_FILES['image']['error'] == 0)
        {
        
    // successful upload of something - do more tests - add rest of upload code
        
    }
    else
        {
        
    $err_code $_FILES['upload_image']['error'];
        
    $output_string .= ($err_code 5) ?  ($err_code 4) ? ($err_code 3) ? ($err_code 2) ? 
        
    'Main Image File was above ' .ini_get('upload_max_filesize'). ' bytes in size.<br />' 
        
    'Main Image File was above ' .$max_upload_size' bytes in size.<br />' 
        
    'Main Image File was only partially uploaded, please try again.<br />' :  
        
    'No Main Image File was Uploaded, please try again.<br />' 
        
    'Unknown Error Encountered, please try uploading again.<br />' ;
        }
    echo 
    $output_string
    the $max_upload_size variable is the same as the MAX_SIZE form field entry that limits the post on the client side.
    teckis - that's news to me.


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
  •