Welcome to the David Walsh Blog! This website was created to reach every audience possible. Please contact me at david@davidwalsh.name to let me know if I can do anything to further improve your experience on this website.

Apache / Server Archives

Set php.ini Values Using .htaccess

Debuted Tuesday, November 4, 2008 @ 8:39 am
Sugar: Apache / Server · PHP

Did you know that you can set php.ini values right inside the .htaccess file? It’s actually very easy.

The .htaccess Code

#format
php_value setting_name setting_value

#example
php_value  upload_max_filesize  10M

Of course you could simply place these in the php.ini file, but .htaccess is a viable alternative if your host doesn’t allow you to touch the php.ini file.

Article Sep

Send Files via FTP Using PHP

Debuted Friday, October 10, 2008 @ 7:41 am
Sugar: Apache / Server · Javascript · PHP

Sending files to a server via FTP is an essential ability of any web developer or designer. Of course, we all use glossy FTP clients like WS_FTP and FireFTP, but what about FTP automation? You can use PHP to FTP files from one server to another. Let me show you how.

The PHP

$connection = ftp_connect($server);

$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);

if (!$connection || !$login) { die('Connection attempt failed!'); }

$upload = ftp_put($connection, $dest, $source, $mode);

if (!$upload) { echo 'FTP upload failed!'; }

ftp_close($connection); 

Obviously, the first task is to connect to the other server. Once the connection is created, you pass the login credentials. Once you’re logged in, you can use the ftp_put() function to send the file. That’s it!

Article Sep

Increase PHP’s File Upload Limit Using php.ini

Debuted Thursday, July 3, 2008 @ 7:01 am
Sugar: Apache / Server · PHP

The file upload size limit is usually set pretty low by shared hosting providers.  Why?  To save bandwidth, keep the server moving quickly, and think about it — how many customers really need a large upload limit?  If you do need to increase the maximum upload limit, all you need to do is place the following code snippet in your php.ini file:

file_uploads = On
upload_max_filesize = 10M //needs to be in {x}M format

Note that not all hosting providers allow customers to increase the file upload limit.  Take that into consideration when purchasing your customer’s web hosting.





 

 

comments twitter