0

I'm trying to upload big files using PHP and it's not working and the size is around 855 ko. I've already tried uploading smaller files and its worked so i'm sure that my problem that causing the error.

I've already tried most of the solution in SO and google but in vain. Some said that i should try to configure my php.ini and i did but without success.

I'm using lighttpd on an embedded system.

My php.ini configuration :

max_execution_time = 300; Maximum execution time of each script, in seconds
max_input_time = 25200; Maximum amount of time each script may spend parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 40M      ; Maximum amount of memory a script may consume (128MB)
file_uploads = On
upload_tmp_dir =/home/imagesdcard/www/
upload_max_filesize = 10M
max_file_uploads=2

I had tried many solutions that suggesting it was caused by certains configurations in php.ini and i had changed it but without success.So, i wanna ask how can i upload big files using php?

Thank you in advance for all advice and help and have a great day.

Syakur Rahman
  • 2,056
  • 32
  • 40
  • 1
    Possible duplicate of [Increasing the maximum post size](https://stackoverflow.com/questions/6135427/increasing-the-maximum-post-size) – Syakur Rahman Jul 18 '19 at 07:33
  • As i'm using lighttpd this lines caused my server to failed when i'm addding those lines @Syakur Rahman – alexhelloworld Jul 18 '19 at 07:50
  • Did you check the log what causes it to fail? Lighttpd shouldn't have any issues with php.ini since it should communicate with php via fastcgi. – Syakur Rahman Jul 18 '19 at 07:53
  • Yup but the error logs show nothing, this is the thing that makes me crazy causes everytime that the files failed to be send , im logging an error in my error log. – alexhelloworld Jul 18 '19 at 07:54
  • No, I am saying the log when the server failed to start. Misconfiguring php.ini shouldn't, in most cases, cause the server fail to start. – Syakur Rahman Jul 18 '19 at 07:56
  • sorry for the misunderstanding. I went to see the link that you provided to see if the questions had been answered before , the answers tell that i shoud add php_value post_max_size 20M php_value upload_max_filesize 20M to my httpd.conf but as i'm using lighttpd, i add those lines in my lighttpd.conf and it gives me this error : source:/etc/lighttpd/lighttpd.conf line:81 pos:27 parser failed somehow near here:post_max_size, lighttpd:error, could not start server – alexhelloworld Jul 18 '19 at 07:59
  • You are adding it to the wrong file. As explicitly said, both in the answer below and the link I gave you, you need to add it to php.ini, not the server's configuration. – Syakur Rahman Jul 18 '19 at 08:04
  • Yup i already add those lines below in my php.ini , the comments that i added above is to see if maybe i had to change also the lighttpd.conf. – alexhelloworld Jul 18 '19 at 08:07
  • Did you confirm that it took effect via phpinfo? – Syakur Rahman Jul 18 '19 at 08:20
  • yes, i run phpinfo() to see is the modifications took place and it did , thats why i'm kinda in a mess try to find the solution for this problem. – alexhelloworld Jul 18 '19 at 08:21
  • `upload_tmp_dir =/home/imagesdcard/www/` Have you checked that you have sufficient disk space? If you replace your php with a CGI script which does `echo -e Status: 200\n\nContent-Length: $CONTENT_LENGTH` does it work when you try to upload larger files? Make sure to enable mod_cgi in lighttpd and configure it to execute your CGI. – gstrauss Jul 19 '19 at 02:01
  • Yes i had checked that i have a sufficient disk space cause i already tried to send files using FIleZilla and it worked. I'm using fastCGI enabled with lighttpd. How to replace my php script with CGI script? I'm working on an embedded systems running on Linux server. – alexhelloworld Jul 19 '19 at 06:06

1 Answers1

1

By configuration, PHP only allows to upload files up to a certain size. There are lots of articles around the web that explain how to modify this limit. Below are a few of them:

For instance, you can edit your php.ini file and set:

memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M

You will then need to restart apache.

Jimit H.
  • 185
  • 1
  • 11
  • Yup i already did that and i tried to increase those values to see if it would be successfull but not. Furthermore, i can see the value changed in my phpinfo() page. – alexhelloworld Jul 18 '19 at 07:41