www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Image Uploading Problem

  1. #1
    Join Date
    Dec 2006
    Posts
    20

    Image Uploading Problem

    Hi

    How to upload greater than 1mb file.its giving error for big size files.


    How to upload max file size images.

    Thanks for any help.

  2. #2
    Join Date
    May 2007
    Location
    Cleveland, OH
    Posts
    1,403
    You have to edit your "post_max_size" and "upload_max_filesize" in your php.ini file then restart apache.

  3. #3
    Join Date
    Dec 2006
    Posts
    20
    Already post_max_size 8m and upload_max_filesize 2m

    but its not taking 1mb file also.

  4. #4
    Join Date
    May 2007
    Location
    Cleveland, OH
    Posts
    1,403
    Are you uploading them to a database? Are there any errors in your Apache/PHP/DB error logs?

  5. #5
    Join Date
    Dec 2006
    Posts
    20
    NO i'm uploading this to folder.i'm not getting any error message.
    but files are not uploading to folder.

  6. #6
    Join Date
    Aug 2007
    Location
    London
    Posts
    410
    can you post the code you're using to upload/move the files?

    You're doing it by having a form, right?

  7. #7
    Join Date
    Dec 2006
    Posts
    20
    This is my code

    $uploadDir = '../articles/';;

    if(isset($_POST['upload']))
    {
    $fileName = $_FILES['userfile']['name'];
    $tmpName = $_FILES['userfile']['tmp_name'];
    $fileSize = $_FILES['userfile']['size'];
    $fileType = $_FILES['userfile']['type'];

    $filePath = $uploadDir . $fileName;

    $result = move_uploaded_file($tmpName, $filePath);
    if (!$result) {
    echo "Error uploading file";
    exit;
    }
    }

    ?>
    <form method="post" enctype="multipart/form-data">
    <table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
    <tr>
    <td width="246">
    <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
    <input name="userfile" type="file" id="userfile">
    </td>
    <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
    </tr>
    </table>
    </form>

  8. #8
    Join Date
    Aug 2007
    Location
    London
    Posts
    410
    First thing that I noticed was here:
    PHP Code:
    $uploadDir '../articles/';; 
    You shouldn't have two semicolons and the file destination has to be in terms of the server, so use
    PHP Code:
    $_SERVER['DOCUMENT_ROOT'
    and put your location in from there, so if on your site the location was "/articles/" then use
    PHP Code:
    $uploadDir $_SERVER['DOCUMENT_ROOT'] . "/articles/"
    Use $_FILES['userfile']['error'] to get more detailed errors rather than "Error uploading file", that might help find the problem.

    I hope that solves it.

  9. #9
    Join Date
    Dec 2007
    Location
    United States
    Posts
    73
    Quote Originally Posted by blue-eye-labs
    First thing that I noticed was here:
    PHP Code:
    $uploadDir '../articles/';; 
    You shouldn't have two semicolons and the file destination has to be in terms of the server, so use
    PHP Code:
    $_SERVER['DOCUMENT_ROOT'
    and put your location in from there, so if on your site the location was "/articles/" then use
    PHP Code:
    $uploadDir $_SERVER['DOCUMENT_ROOT'] . "/articles/"
    Use $_FILES['userfile']['error'] to get more detailed errors rather than "Error uploading file", that might help find the problem.

    I hope that solves it.
    relative links have always worked for me

  10. #10
    Join Date
    Aug 2007
    Location
    London
    Posts
    410
    oh, I've always had that problem that they just wouldn't work until I put $_SERVER['DOCUMENT_ROOT'] in, and then they worked fine. I kept getting thrown permissions errors.

  11. #11
    Join Date
    Dec 2006
    Posts
    20
    i changed my code according to ur post ,still i'm getting errors.

    Small Size files are uploading but 1mb or greater than 1mb files are not uploading.

  12. #12
    Join Date
    May 2007
    Location
    Cleveland, OH
    Posts
    1,403
    Are there any errors in the PHP or Apache error logs when you upload photos > 1mb?

  13. #13
    Join Date
    Dec 2006
    Posts
    20
    Page can't be found is coming.when i refresh the page its coming html form
    i'm not getting any errors.

  14. #14
    Join Date
    May 2007
    Location
    Cleveland, OH
    Posts
    1,403
    so your getting a page not found error when you submit the form?

    have tried setting your form action to $_SERVER['PHP_SELF']?
    HTML Code:
    <form method="post" enctype="multipart/form-data" action="<?=$_SERVER['PHP_SELF']?>">

  15. #15
    Join Date
    Dec 2006
    Posts
    20
    I tried ur code its not working.
    but small size files are uploading properly.greater than 1m files are not uploading.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles