Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

uploading with ftp functions problem

Status
Not open for further replies.

Guest
hello everyone!

i have an annoying problem while trying to connect to an ftp server via php's ftp functions in order to upload some files. here's the code:

Code:
$ftp_conn=ftp_connect('[URL unfurl="true"]www.mysite.com')[/URL] or die     ("Couldn't connect to FTP server");
	echo "sdf";
	echo ($ftp_conn);
	echo(ftp_login($ftp_conn,"username","password"));
	ftp_chdir($ftp_conn,"offersys");
	ftp_pwd($ftp_conn);
	ftp_chdir($ftp_conn,"images");
	ftp_pwd($ftp_conn);
	ftp_fput($ftp_conn,$fname,$filetmp,FTP_BINARY);
I always get the "Couldn't connecto to FTP server" error, at the first line of code, while trying to connect. string. What is wrong here?? I have tried shutting firewalls etc. but with no success.

Any help will be highly appreciated.
Thanks in advance,
vlakas
 
yes, i even have the option of using my own php.ini file. i have also checked and the ftp functions are supported (i used the phpinfo() function and the ftp library shows up)
 
yes i can resolve the address (i have even tried to use the ip address directly, and the gethostbyname function), and i can connect via an ftp client to the server.
any other suggestions?? this is really becoming a nightmare!!

 
Questions:
You can connect with a client from where?
What is the setting for the connection timout?
So, you have a firewall?

Try fsockopen() to the server's port 21 (standard FTP) or log into the shell of the server and try
telnet 21
That will show if you can connect from your server.
(If the FTP server answers logout with 'quit').
 
i can ftp with an ftp client to the remote server from anywhere, including the machine viewing the ftp page.
the settings are the default timeout settings (90 secs i think). when connecting from an ftp client the connection is immediate, so i don't think this is the problem.
the problem is somewhere in the php script or module of the server (php 4.1.1) i think.

am i the only one having trouble with this function??


 
Sorry, but on my system your script (with changes for FTP server, file to upload, etc) works.

I agree with DRJ478. If at all possible, upgrade PHP.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
no can do! my isp says it is stable, so it is good!! any way around that then?? any other way to upload a file in a directory at the server where my web page is?? i tried the normal way (http file upload) but i have no write permissions to the server from the php scripts. any way to submit username/password?? i asked my isp to give write permissions to the apache process, but they say it cannot be done, and that i need to pay in order to create a new ftp account for the internet user... i really don't understand them..
 
Direct the managers of your ISP to the PHP changelog and point out to them how many bugs have been swatted in the product since the release of 4.1.1 (It was released December 26, 2001.)

Better still, find another hosting provider.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top