473,774 Members | 2,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\dir ectory\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\directo ry\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="multip art/form-data">
Source File:<input type=file name=source_fil e 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($se rver);
$user = "user";
$pass = "password";
//destantion file
$destination_fi le = "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_fi le, $source_file, FTP_BINARY)){
echo "$source_fi le wasent uploaded";
} else {
echo "$source_fi le 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($s ource_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 4673
Just another register_global s 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\dir ectory\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\directo ry\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="multip art/form-data">
Source File:<input type=file name=source_fil e 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($se rver);
$user = "user";
$pass = "password";
//destantion file
$destination_fi le = "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_fi le, $source_file, FTP_BINARY)){
echo "$source_fi le wasent uploaded";
} else {
echo "$source_fi le 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($s ource_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
1813
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( $Submit )) { $ftp_server = "ftp_site"; $ftp_user_name = "username"; $ftp_user_pass = "password";
2
2629
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 Web-Server. I start this php-code from HTML with <FORM ENCTYPE="multipart/form-data" ACTION="test.php" METHOD=POST > .....
4
3286
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" I can connect, log on and change directories just fine.
5
6751
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 directions. I am connecting because I am not getting an error. I am also logging in with the username and password because I am not getting an error here as well. But so far no matter what I do, the file will not upload. Any help with this would be...
1
3136
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. When it's not working i've check the connectiion and done a manual upload with a proprietry ftp program and all is fine. Any ideas? http://eye.cc -php- web design
5
5536
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 except ftp_put and ftp_get functions. They return always false. I tried to set passive mode, it doesn't help. Any advice will be appreciated.
3
21304
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"; // root level $file = "/upload/ITS_BLI_0".$_POST.".csv"; // this file dir is root/manager/posts/
0
1688
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 #11,fairmont_mon.txt,/tmp/phpWmPlSJ Warning: ftp_put() : OOPS: vsf_sysutil_bind in /var/www/html/hview/hqc/twc_upload/upload_file.php on line 263
1
6124
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 have it in the script), and for now, I have the mode set to passive (although I'll give a choice later on when I actually implement the script). (I starred out the password here, it is in the file, though.) Here's the entire page (not much, just the...
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.