In my php code, I make for user for upload their files, to ftp. For several months, its work. No problem at all. But recently they said cannot upload their files, which is larger than 5MB. Previously, they can upload for 300MB or more. I ask my hosting, but they say that their network is OK. I tested my code on localhost, and it can upload even more than 1 GB data! Any ideas about that trouble?

Dani AI

Generated

For and anyone hitting the same symptom (small uploads OK, >5MB failing while the same code works on localhost): the problem is almost always an environment limit or transfer/path difference rather than PHP logic. was right to ask for logs; is correct that timeouts and network middleboxes often show up as size-dependent failures; and ’s reminder about client-side changes is worth checking last to isolate the server path first.

Checklist to triage (run these from the hosting environment and collect exact error lines):

  • Confirm PHP limits: upload_max_filesize, post_max_size, max_execution_time, max_input_time, memory_limit, and upload_tmp_dir. Produce a quick phpinfo or run ini_get for those values and keep the output.

  • Check disk and temp space/quotas: df -h, inspect upload_tmp_dir size and permissions, and check per-user quota if on shared hosting.

  • Inspect webserver/proxy limits and timeouts: nginx client_max_body_size, Apache LimitRequestBody, FastCGI/Proxy timeouts (e.g. fastcgi_read_timeout, FcgidIOTimeout) and any mod_security rules that block large posts.

  • Test the FTP hop independently (to rule out PHP): from the host, try a raw upload with curl:

    curl -T bigfile.bin ftp://user:pass@ftp.example.com/ --ftp-pasv

    and check the FTP server logs (vsftpd/proftpd/pure-ftpd). Also verify passive vs active mode and any per-account quota.

If PHP-to-FTP transfers are used, avoid loading whole files into memory and prefer streaming or non-blocking FTP so timeouts are less fatal. Example non-blocking FTP upload pattern:

$conn = ftp_connect($host, 21, 90);
ftp_login($conn, $user, $pass);
ftp_pasv($conn, true);
$ret = ftp_nb_put($conn, $remote, $local, FTP_BINARY);
while ($ret === FTP_MOREDATA) { $ret = ftp_nb_continue($conn); }
ftp_close($conn);

If host settings cannot be changed, switch to chunked uploads (client-side 5–10MB pieces, reassemble server-side) or transfer via SFTP/SSH (single-port) which is less likely to be broken by intermediate firewalls.

Collect the exact error messages from PHP/webserver/FTP logs and post them when asking hosting support; those lines will point directly to whether it is an ini limit, a proxy timeout, a quota, or a firewall drop.

Recommended Answers

All 4 Replies

How is this script working? Through command line or through web interface? Do you have access and error logs of the web server (in case of web interface) and of the FTP server?

My encounter with this had various end user problems. The short list is: they changed browsers, security suites and had malware.

: script was working through web interface. I'll check error logs. Not thought before! Thanks :)

Does your script has a connection time out? This can happen if the end user's internet connetcion is slow and also if they are also behind the proxy or their network connection has some blockings in sertain ports. In my case it was the network which had certain ports being blocked so I wasn't able to access but if they can access, maybe your script/server has some sort of time out which will result in those who are using slow connection not being able to upload large files.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.