upload file via ftp from ftp in PHP

Stefano Linguari

i search a lot on internet but i don't find a solution. I need copy a file from a ftp to my ftp server through php. Later i need also create a cron job but is another problem.

I tested various script PHP like this below but i receive always the same problem(i try with absolute, normal and other path :) ):

connected Warning: ftp_put(): Can't open that file: No such file or directory in /web/htdocs/www.stanem.it/home/csv/importinnovacsv.php on line 20 There was a problem while uploading /web/htdocs/www.stanem.it/home/csv/test.csv

what i have to do?

<?php
$ftp_server="ftp.xxxx.it";
$ftp_user_name="user";
$ftp_user_pass="psw";

// connect and login to FTP server

$ftp_conn       = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login          = ftp_login($ftp_conn, $ftp_user_name, $ftp_user_pass);


if($login) {
   echo 'connected<br>'; 

   $local_file = '/web/htdocs/www.stanem.it/home/csv/test.csv'; //where i need to put file
   $server_dir = 'ftp://15886:[email protected]'; //where i copy the file


   // upload a file
   if (ftp_put($ftp_conn, $server_dir, $local_file, FTP_ASCII)) {
       echo "successfully uploaded $local_file\n";
       exit;
   } else {
       echo "There was a problem while uploading $local_file\n";
       exit;
   }


} 
Martin Prikryl

The $remote_file argument of ftp_put is a path to the file on the FTP server.

You are passing a URL (and it even misses any path or file name).

It should be like:

$remote_file = "/remote/path/test.csv";

Once you resolve the path problem, you will also likely face data connection problems, as your are using the default active mode. See PHP ftp_put fails.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PHP upload to FTP from file contents

From Dev

Upload text file to Google uploads via PHP FTP PUT

From Dev

Upload a ZIP file and UNZIP ftp folder via PHP

From Dev

not able to upload file to server via ftp/ cpanel

From Dev

How to Download file from one FTP and then Upload file to different FTP?

From Dev

Upload files from a list via ftp in bash

From Dev

Upload single image file to FTP using PHP

From Dev

Upload a .zip file to FTP and unzip it using PHP

From Dev

Upload a file to a server using FTP using php

From Dev

Upload single image file to FTP using PHP

From Dev

Upload a .zip file to FTP and unzip it using PHP

From Dev

Ajax upload a file from browser to FTP server

From Dev

Upload a file to an FTP server from a string or stream

From Dev

Download file from url and upload into ftp

From Dev

FTP File upload from Memory in C

From Dev

Ajax upload a file from browser to FTP server

From Dev

FTP File upload from Memory in C

From Dev

Dynamic Upload file to FTP

From Dev

How do you upload a core PHP file via FTP without interrupting a visitor to your site

From Dev

How do you upload a core PHP file via FTP without interrupting a visitor to your site

From Dev

FTP via batch file

From Dev

Upload files via FTP - Safety

From Dev

FTP via PHP Error

From Dev

How to upload separate HTML file to wordpress site via FTP client?

From Dev

Create a CSV File and Upload to Server via FTP in MVC / C#

From Dev

How to upload separate HTML file to wordpress site via FTP client?

From Dev

Null Reference Exception when trying to upload a file via FTP

From Dev

Create a CSV File and Upload to Server via FTP in MVC / C#

From Dev

Ftp file upload- android

Related Related

HotTag

Archive