Errors caused by file upload

Discussion in 'PHP' started by encom, Jun 25, 2009.

  1. #1
    I have this file upload script that seems to work perfectly. The only problem is, when I upload a large file the server returns a 500 server error. What is all that about?

    Hope you can help. Thanks.
     
    encom, Jun 25, 2009 IP
  2. nishanair

    nishanair Active Member

    Messages:
    188
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    most probably, problem is with execution time
     
    nishanair, Jun 25, 2009 IP
  3. encom

    encom Member

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Thats what I thought, it takes a long time and therefore returning the error. is there a setting that i can change for execution time ?
     
    encom, Jun 25, 2009 IP
  4. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you have access to the php.ini file then you can change this.
    Also note that you might have to increase the maximum upload limit as well.

    :)
     
    Wrighty, Jun 25, 2009 IP
  5. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #5
    Maybe your host doesnt need a 777 chmod at the place u upload ur files make this 755 and try if the error still exist
     
    Bohra, Jun 25, 2009 IP
  6. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    that wouldn't cause a 500 ISE
     
    Wrighty, Jun 25, 2009 IP
  7. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #7
    It does in some host i dont know why but it does has happened in the past for me
     
    Bohra, Jun 25, 2009 IP
  8. SHOwnsYou

    SHOwnsYou Peon

    Messages:
    209
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Put set_time_limit(0); at the top of your script.
     
    SHOwnsYou, Jun 25, 2009 IP
  9. encom

    encom Member

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #9
    My host has dissabled that code for security reasons :( so I place:
    php_value max_execution_time 100
    in my .htaccess file and I am still getting the error with the files :(
     
    encom, Jun 26, 2009 IP
  10. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You will need to contact your host - what is the size of the file that's being uploaded & furthermore, have you checked through php_info what your max execution time is?


    Try this at the top of your Script:
    ini_set('max_execution_time', 0);
    Code (markup):

    :)
     
    Wrighty, Jun 26, 2009 IP
  11. encom

    encom Member

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #11
    "ini_set('max_execution_time', 0);"

    No, that didnt work.

    hmmmmmmm :confused:

    and the exicution time is at the default of 30 seconds but I have got 100 seconds in my .htaccess file
     
    encom, Jun 26, 2009 IP
  12. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Are you sure your host doesn't have a max file size limit
     
    wd_2k6, Jun 26, 2009 IP
  13. encom

    encom Member

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #13
    Ahh, ive just spoken to my host and they have a max of 2megs and it cant be changed.

    (sigh)

    There is a saying: there is always a way...

    is that the case here?
     
    encom, Jun 26, 2009 IP
  14. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Maybe somebody could provide you with a hack around it, but it's pretty likley to get you banned from your host as soon as they find out.

    Alternative is to host the uploaded files elsewhere, or uprgrade/change with your original host.

    There are many hosting sites out there some paid some free for your files, but be careful to check out whether they allow hotlinking, file sizes, file types etc because nothing is for free in this world :)

    What are you allowing your users to upload pictures, music, anything they want?
     
    wd_2k6, Jun 26, 2009 IP
  15. encom

    encom Member

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #15
    ok thanks for that. err flash files mainly. I think that finding an external place to host files is the best option.
     
    encom, Jun 26, 2009 IP
  16. Mega B

    Mega B Well-Known Member

    Messages:
    3,454
    Likes Received:
    66
    Best Answers:
    1
    Trophy Points:
    190
    #16
    What script are you using ???
     
    Mega B, Jun 26, 2009 IP
  17. encom

    encom Member

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #17
    Just a simple one that i knocked up myself
     
    encom, Jun 26, 2009 IP
  18. Rask

    Rask Active Member

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #18
    Contact your host. they should be able to sort it out for you.
     
    Rask, Jun 26, 2009 IP
  19. SGBoise

    SGBoise Peon

    Messages:
    647
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #19
    There are several other settings besides max_execution_time that can cause uploading problems. Try increasing these settings especially when uploading using post.

    max_input_time = 300
    memory_limit = 128M
    post_max_size = 256M
    upload_max_filesize = 256M
     
    SGBoise, Jun 26, 2009 IP
  20. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Yo'll need a server to be able to chqnge most those settings. A VPS will do. :)
     
    Wrighty, Jun 28, 2009 IP