By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,641 Members | 1,685 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,641 IT Pros & Developers. It's quick & easy.

ftp_put puts empty file =\

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.