472,952 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,952 software developers and data experts.

ftp_put puts empty file =\

Hi, im trying to upload a file from a client (windows) to an ftp
server (linux), i deciede to use some of php`s functions to connect
and authenticate etc.. i only wish to put a file on the server, so i
used ftp_put() function, when i send the file via http, the file is
created on the server, but it is empty, i checked the permissions and
all are set correctly, i figured if it is empty it means it cant find
the file im trying to upload, i read somewhere that it has problems
with recognizing windows directory strings
e.g(F:\this\directory\file.txt), i tryd minipulating the string but it
still couldnt find the file, i figured that ftp_put sees the absolute
path to the file from a windows box as the file name itself, so it
maybe thinks F:\this\directory\file.txt is the actual file name, and
dosent interpret the directory names, i really tryed every think i
could think of, and nothing worked, here is the index.html and
upload.php files that i used:

index.html
---------------------------------
<html>
<body>
<p>upload</p>
<P>
<form method=POST action="upload.php" enctype="multipart/form-data">
Source File:<input type=file name=source_file size=20><BR>
<input type=submit name=Submit value=Submit size=20 style="border: 1px
solid #0000FF"></form>
</body>
</html>
upload.php
----------------------------------
<?php
$server = "localhost";
$con = ftp_connect($server);
$user = "user";
$pass = "password";
//destantion file
$destination_file = "file.txt";
ftp_login ($con, $user, $pass);
//change directory to files where the permissions are set to 0777
ftp_chdir($con, "files");

//this is where it goes wrong.
if (!ftp_put($con, $destination_file, $source_file, FTP_BINARY)){
echo "$source_file wasent uploaded";
} else {
echo "$source_file was uploaded";
}
//close connection
ftp_close($con);
?>

---------------------------------------------

let me add, that when i echo`d the $source_file i noticed it
displayed a blank, is that because im using the POST method ?, and
when i use the GET method i see the directory as F:\\files\\file.txt ,
so i used echo stripslashes($source_file); , but it still didnt
find the file, if someone can find a flaw in what im doing please
tell, also is there another method of transfering files to an ftp
server via http without using php ?
thank you
Jul 17 '05 #1
1 4575
Just another register_globals problem.

balzano_1 wrote:
Hi, im trying to upload a file from a client (windows) to an ftp
server (linux), i deciede to use some of php`s functions to connect
and authenticate etc.. i only wish to put a file on the server, so i
used ftp_put() function, when i send the file via http, the file is
created on the server, but it is empty, i checked the permissions and
all are set correctly, i figured if it is empty it means it cant find
the file im trying to upload, i read somewhere that it has problems
with recognizing windows directory strings
e.g(F:\this\directory\file.txt), i tryd minipulating the string but it
still couldnt find the file, i figured that ftp_put sees the absolute
path to the file from a windows box as the file name itself, so it
maybe thinks F:\this\directory\file.txt is the actual file name, and
dosent interpret the directory names, i really tryed every think i
could think of, and nothing worked, here is the index.html and
upload.php files that i used:

index.html
---------------------------------
<html>
<body>
<p>upload</p>
<P>
<form method=POST action="upload.php" enctype="multipart/form-data">
Source File:<input type=file name=source_file size=20><BR>
<input type=submit name=Submit value=Submit size=20 style="border: 1px
solid #0000FF"></form>
</body>
</html>
upload.php
----------------------------------
<?php
$server = "localhost";
$con = ftp_connect($server);
$user = "user";
$pass = "password";
//destantion file
$destination_file = "file.txt";
ftp_login ($con, $user, $pass);
//change directory to files where the permissions are set to 0777
ftp_chdir($con, "files");

//this is where it goes wrong.
if (!ftp_put($con, $destination_file, $source_file, FTP_BINARY)){
echo "$source_file wasent uploaded";
} else {
echo "$source_file was uploaded";
}
//close connection
ftp_close($con);


---------------------------------------------

let me add, that when i echo`d the $source_file i noticed it
displayed a blank, is that because im using the POST method ?, and
when i use the GET method i see the directory as F:\\files\\file.txt ,
so i used echo stripslashes($source_file); , but it still didnt
find the file, if someone can find a flaw in what im doing please
tell, also is there another method of transfering files to an ftp
server via http without using php ?
thank you

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joseph Markovich | last post by:
I'm trying to write a script for my users to be able to upload large files, and now I am unsure what exactly I am doing wrong. My script is based on the one in the PHP manual. <?php if(isset(...
2
by: Udo Pecher | last post by:
I apply the following code test.php $upload =ftp_put($conn_id,"test.jpg","$dat",FTP-BINARY); where $dat is a local filename which I like to move via FTP. "test.jpg" ist the filename on the...
4
by: selywork | last post by:
I am just trying a simple up load of a file on my hard drive to my ftp site. $source_file="file://C:/1PRV.TXT"; I get the error "remote host file access not supported, file://C:/1PRV.TXT" ...
5
by: tripwater | last post by:
Hello, I am having problems with the ftp_put() function. I can login via shell prompt. Does anyone know why the ftp_put() function may not work? I went to the php site and followed the...
1
by: excession | last post by:
I've got a script which uploads a few files to a remote server. The problem is the ftp_put command hands and the script eventually times out. What is even more strange is sometime it works fine. ...
5
by: Alex | last post by:
I'm trying to make simple ftp client, used the following article for base: http://www.devarticles.com/c/a/PHP/Building-An-FTP-Client-With-PHP/3/ All works, I can login, see list of files, but...
3
by: empiresolutions | last post by:
ftp_put() is not working. this is what i have. $host = "www.site.com"; $ftp_user_name = "username"; $ftp_user_pass = "password"; // declair files $remote_file = "ITS_BLI_0".$_POST.".csv";...
0
by: sushil | last post by:
Hello Frnds, I am getting problem in uploading file from php script. The error is : Code - $upload = ftp_put($conn_id,$filemax,$src,FTP_BINARY); Output - Resource id...
1
by: PehJota | last post by:
I'm kinda new to PHP, and I'm trying to make a simple FTP upload script. It successfully connects to the server and logs in, but it can't upload. The transfer mode I use normally is ASCII (like I...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.