#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    8
    Rep Power
    0

    File uploads and losing post variables.


    Hi,

    I'm using a function :

    PHP Code:
    function uploadImage($image$tempfile$myid
    {
     
    $errors=0
    if (
    $image)
     { 
    $filename clean($image);
     
    $extension getExtension($filename);
     
    $extension strtolower($extension);

     if ((
    $extension != "jpg") && ($extension != "jpeg") && ($extension !="png") && ($extension != "gif")) 

    echo 
    '<h1>Unknown extension!</h1>'
    $errors=1

    else { 
    $size=filesize($tempfile);
     if (
    $size 5120000
    {
     echo 
    '<h1>You have exceeded the size limit!</h1>'$errors=1
    }
     
    $image_name=$filename
    if ( 
    file_exists "userUploads/$myid)) { $newname="userUploads/" .$myid "/" .$image_name;
     } 
    else { 
    mkdir("userUploads/$myid"0777); $newname="userUploads/".$myid "/" .$image_name

     if (!
    move_uploaded_file($tempfile$newname)) 

    echo 
    '<h1>Copy unsuccessfull!</h1>'$errors=1; }}} if(!$errors) { echo "<h1>File Uploaded Successfully!</h1>"; } } 
    It works well if the file is about 1MB or below, but when it hits 2-3MB (which many of the pictures are, it is taking and resizing photos into display pictures), it loses all the other post data sent along with it (it is part of a registration form).

    How do I get around this? My users are generally not ept enough to be required to resize themselves.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    What do you mean it loses all the other post data? How do you know that? is the page reloading or timing out?
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    8
    Rep Power
    0
    Sorry, I should have been more clear.

    The form is being submitted with:

    Code:
    <input type='submit' name='edit'>
    But the time the uploading takes causes the following if statement to return true:

    Code:
    if (!isset($_POST['edit']))
    Instead of the corresponding isset statement that handles the image upload, resize and database entry.
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    If the post data, including files, exceeds post_max_size all of the post data is discarded. You'll need to adjust the server configuration to increase this option.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    8
    Rep Power
    0
    I was thinking it may be a max size or something and you are very correct, the max post size is 2MB.

    I'm going to fix that now,

    thanks for the replies!

IMN logo majestic logo threadwatch logo seochat tools logo