[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


php ftp problem

Posted on 2006-04-19
Medium Priority
Last Modified: 2009-07-29
I am using the following code to ftp images to the server.  This code works fine for small files but Fails for files that are 1mb or more.

I need to ftp files of 8 and 9MB Is there a setting to allow larger ftp's?


// set up basic connection
$ftp_server = "ftp.mysite.com";
$conn_id = ftp_connect($ftp_server);

// login with username and password
$ftp_user_name = "name";
$ftp_password = "password";
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_password);

// check connection
if ((!$conn_id) || (!$login_result)) {
       echo "FTP connection has failed!\n";
       echo "Attempted to connect to $ftp_server for user $ftp_user_name";
   } else {
       echo "Connected to $ftp_server, for user $ftp_user_name";
// upload the file  

$destination_file = './new.pdf';
$source_file = $_FILES['imagefile']['tmp_name'];
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_ASCII);

// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
// close the FTP stream
Question by:jimfrith

Assisted Solution

Tempting_Fate earned 1000 total points
ID: 16495269
I think you might have to change the configurations in your php.ini file.

Author Comment

ID: 16501321
I have already altered the ini withthe following

php_value upload_max_filesize "25M"
    php_value post_max_size "35M"
    php_value memory_limit "70M"
    php_value max_execution_time "0"

I think there may be another setting that is limiting my filesizw I thought it might be in the php.conf file but There does not appear to be a php.conf file on our server.

Any suggestions?

Accepted Solution

floorman67 earned 1000 total points
ID: 16510298
open php.ini ...

find ....

"max_execution_time = 30     ; Maximum execution time of each script, in seconds"

higher file sizes take longer to uplaod and is probably timing out your script execution checks ...

increase the number ...

save the file ...

restart server.

test it

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month18 days, 15 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question