473,396 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 4628
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.