473,788 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ftp_put() problems

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 great.

code:
$query = "select Server, UserName, Password, Destination_Pat h,
ServerType from company";

$result = @mysql_query($q uery);

$row = @mysql_fetch_ar ray($result);

if (!empty($row["Server"]))
{
$hostip = gethostbyname($ row["Server"]);
$conn_id = ftp_connect($ho stip);

// set up basic connection
//$conn_id = ftp_connect($ro w["Server"]);

// login with username and password
$login_result = ftp_login($conn _id, $row["UserName"],
$row["Password"]);

// check connection
if ((!$conn_id) || (!$login_result ))
{
$value = "FTP connection has failed!<br>
Attempted to connect to ".$row["Server"]." for user ".$row["UserName"];
exit;
}

// IMPORTANT!!! turn passive mode on
//tried this and it did not help
//ftp_pasv ( $conn_id, true );

//parameters are ftp_put($conn_i d, $destination_fi le, $source_file,
FTP_BINARY)

$upload = ftp_put($conn_i d, $row["Destination_Pa th"]."/".
strtolower(trim ($HTTP_POST_FIL ES['userfile']['name
'])), strtolower(trim ($HTTP_POST_FIL ES['userfile']['name
'])), FTP_BINARY);

if (!$upload)
echo $upload."<br><b r>Did not upload to ftp server.";

// close the FTP stream
ftp_close($conn _id);
}
I am not getting any errors and the file is not getting uploaded.

-my server var holds the URl of the server ex. 'test.com'

- my destination file var holds the path temp

so the destination path when I echo it is temp/my file

so the ftp_put() is getting passed

ftp_put($conn_i d, 'temp/myfile', 'myfile', ftp_binary);

This is the first time I have ever used this function so please bear
with me. I have researched it and no one seems to have this problem.
Most people complain that the file seems to get uploaded but its file
size is 0. Right now, my page runs and nothing happens. My permissions
on the server are correct, the folder I am trying to upload to exists,
the username and pass are correct and I can login via shell prompt as
well.

Any ideas?
Thanks

Jul 17 '05 #1
5 6753
> $upload = ftp_put($conn_i d, $row["Destination_Pa th"]."/".
strtolower(trim ($HTTP_POST_FIL ES['userfile']['name
'])), strtolower(trim ($HTTP_POST_FIL ES['userfile']['name
'])), FTP_BINARY);

Make sure the destination path is a single filename... no folders, if it
is in a different folder change directory's to that folder.

Next make sure that your source file has the full path otherwise how is
it going to know what file to send?

also claiming binary is a good thing but this script looks like it
directly takes a users input and places it on the server... so what
happens when you get a text file... if this is user input you should
really screen out some files and check for viruses against that file.

Thats about it.

Mike
Jul 17 '05 #2
Thank you for the reply. I will try what you suggested. One thing I am
curious about is why would I need the full path to the source file?

For example, why do I not have to pass in the full path when just
uploading a file like this:

move_uploaded_f ile($HTTP_POST_ FILES['userfile']['tmp_name'],
$path."/".$HTTP_POST_FI LES['userfile']['name']) I do not give it the
full path, just the tmp name of the file. I thought that having access
to the post file[userfile][name] would be enough.

Thanks again for your time

Jul 17 '05 #3
Another thing I am confused about (forgive my lack of knowledge here)
but I do not see how to change directories from the site server. For
example if I call

// current directory
echo getcwd();

I will get the CWD of the current file I am in on the website, not the
current folder I am trying to ftp into remotely. If I call
chdir('public_h tml/temp') this is not on the sever the website you are
currently uploading from.

So I do not understand how to chg dirs on a remote server that you are
trying to ftp to using php and it not look at the server you are
currently sitting on.

Can you please clarify because I am really confused.

Thanks

Jul 17 '05 #4
I have tried uploading directly to the root folder and it still does
not work. Can maybe someone show me a example of the proper way to use
this function? I have looked at a few examples and I thought I had my
code laid out like the examples. I have also check file/folder
permissions and this is not an issue.

Thanks again

Jul 17 '05 #5
empiresolutions
162 New Member
I am haveing the same issue with ftp_put() not working. I have ftp_pasv() on, pathed right. please help
Apr 13 '06 #6

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";
1
4677
by: balzano_1 | last post by:
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...
2
2631
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 > .....
1
3144
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
8801
by: Corky | last post by:
This works: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID = PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) - DAYS(PROBLEMS.CLOSE_DATE)) = 365 AND PROBLEMS.CLOSE_DATE IS NOT NULL But this doesn't: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS
5
5538
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
21305
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
1689
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
9656
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
10172
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
10110
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,...
1
7517
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
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
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
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
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
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.