MyBB Community Forums

Full Version: PHP FTP upload
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
One of the biggest problems with my Downloads Manager plugin is that PHP POST file size limit which usually defaults to 2MB, and is not enough for some people's needs (myself included). So, I've been looking in to ways to get around that, and so far one of the most promising methods is the PHP FTP upload functions.

I've read how to use them, but I'm still a bit confused on the limitations for them, and I figured that, rather than go register at yet another forum so I can make 2 or maybe 3 posts I would ask here where (hopefully) I can get the answers I need just as well.

My confusion stems from the fact that the PHP is executed on the web server, so how does it use FTP to get the file from the user's computer to the FTP server? Does it use the POST method to get the file from the client to the web server, then FTP to get it to the FTP server? Or does it bypass POST altogether and go straight from the client's computer to the FTP server?

I'm hoping that this will solve the file size limit problem, but if not I don't want to rip apart my plugin only to find out it doesn't solve anything.
Do you use Apache?

Then you can set the following paramenter in your .htaccess:

php_value upload_max_filesize 200M
php_value post_max_size 200M

Maybe you have to increase the execution time and memory limit too (if someone upload a big image):

php_value memory_limit 64M
php_value max_execution_time 300
What about plugin users that aren't allowed to do that for one reason or another? It's them that I'm thinking of right now. It would be nicest if I could make it so my plugin just worked, rather than making the user go in and make changes to their server configuration.
PHP can act as a FTP client. That doesn't help you with posting in the browser at all though. Most likely, a host that's so restrictive that it allows only 2MB post size, won't allow you to use FTP or HTTP connections either.

The only way for you to get around the post limit would be to ask the user to split the file into chunks that are smaller than the limit, and once the user uploaded all chunks separately, concatenate them into one file on the server.

However that's cumbersome and most (windows) users do not know how to split a file to begin with, so... nothing you can do about it really. Getting a proper host is the users responsibility. Don't worry about it.
But it would help cut down on the "It doesn't work" support threads. I'll look into it more, but testing any changes is not going to be fun. If I can't get it to work properly then I'll stick with the POST method I've already got.
I have been getting the authorization code error.