How to get the maximum upload file size possible in PHP
Lets say you build websites for different servers the chance that the maximum upload size differs on these servers might be big. So, you want to automatically handle this.
In the following example we simply get the sizes who have influence on the maximum upload possible. Note that you can set the upload_max_filesize to a really big value but you still need memory to handle the file in most cases!
With the following example you can get the lowest possible value and use that in your script to handle as upload maximum.
$max_upload = (int) ini_get('upload_max_filesize'); $max_post = (int) ini_get('post_max_size'); $memory_limit = (int) ini_get('memory_limit'); $upload_mb = min($max_upload, $max_post, $memory_limit); echo $upload_mb;
This example gets the value in MegaBytes.
How to use Bash to upload a file via FTP
This script is a simple example how you can use BASH to upload one or more files to a FTP server.
if [[ "${debug}" = "YES" ]]; then verbose="-v" else verbose="-V" fi ftp -i -n -q 10 "${verbose}" < <EOF open "${ftp_host}" "${ftp_port}" quote USER "${ftp_user}" quote PASS "${ftp_pass}" quote CWD "${initial_directory}" binary put "${file}" "${file_name}" quit EOF
Another script that I wrote on a boring evening. I don't use it these days anymore but it might be useful for you




