6 Replies - 247 Views - Last Post: 20 July 2012 - 12:35 PM Rate Topic: -----

#1 mshadow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 03-July 12

ftp connection

Posted 14 July 2012 - 03:19 AM

hey guys......
i am trying to connect to my WAMP server named localhost by ftp_connect();
  $conn_id=ftp_connect('localhost');
  if(!conn_id)
  echo "error in connection";
 else
   echo "connected";
  

but its displaying "error in connection"
i tried to use 127.0.0.1 instead of localhost and i also turned on the ftp server facilities of windows but nothing is happening.....
any help is highly appreciated
:)

Is This A Good Question/Topic? 0
  • +

Replies To: ftp connection

#2 compactbrain  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 35
  • Joined: 21-January 10

Re: ftp connection

Posted 14 July 2012 - 08:13 AM

Hi mshadow,

I dont have much experience with php ftp connections, but I have spotted an error in your code

 $conn_id=ftp_connect('localhost');
 //if(!conn_id) you have forgotten to put the $ in. it should be
   if(!$conn_id)
 echo "error in connection";
else
  echo "connected";



Assuming you have a FTP server set up correctly I see no reason it wouldn't work, but I could be missing something.
Also you didn't specify a port for your connection. This shouldn't matter as the default is port 21, which is correct assuming you didn't change it when setting up your ftp server.

Let me know if it works for you :)
Was This Post Helpful? 0
  • +
  • -

#3 mshadow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 03-July 12

Re: ftp connection

Posted 14 July 2012 - 10:11 AM

View Postcompactbrain, on 14 July 2012 - 08:13 AM, said:

Hi mshadow,

I dont have much experience with php ftp connections, but I have spotted an error in your code

 $conn_id=ftp_connect('localhost');
 //if(!conn_id) you have forgotten to put the $ in. it should be
   if(!$conn_id)
 echo "error in connection";
else
  echo "connected";



Assuming you have a FTP server set up correctly I see no reason it wouldn't work, but I could be missing something.
Also you didn't specify a port for your connection. This shouldn't matter as the default is port 21, which is correct assuming you didn't change it when setting up your ftp server.

Let me know if it works for you :)

i put $ in the original code,i mistaked it here......but it keeps showing the same error...
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3047
  • View blog
  • Posts: 4,562
  • Joined: 08-June 10

Re: ftp connection

Posted 14 July 2012 - 01:30 PM

Are you sure that the FTP server is running properly? Have you tried connecting to it with a FTP client, like FileZilla?

There is nothing wrong with the code you posted. If the FTP server is really running on localhost, using port 21, then you should be connected. The error must be on the other end, with the FTP server.
Was This Post Helpful? 0
  • +
  • -

#5 compactbrain  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 35
  • Joined: 21-January 10

Re: ftp connection

Posted 14 July 2012 - 06:46 PM

I'm sorry that didn't work for you, I love an easy fix :)
If you can give more details about your setup it might help. I have setup windows FTP server on my laptop and that code works for me (windows 7, PHP 5.3). Try filezilla like Atli said and post back.
ENJOY:)
Was This Post Helpful? 1
  • +
  • -

#6 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 994
  • View blog
  • Posts: 3,547
  • Joined: 05-June 09

Re: ftp connection

Posted 15 July 2012 - 05:29 AM

WAMP doesn't have an FTP Server included, have you installed one in addition? If not, it's obviously not going to work.

You should install something like the Filezilla Server, which will give you FTP Server abilities. You can also watch the logs whilst you're debugging your PHP to see if any connections get through to the server.
Was This Post Helpful? 0
  • +
  • -

#7 mshadow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 03-July 12

Re: ftp connection

Posted 20 July 2012 - 12:35 PM

View Postcompactbrain, on 14 July 2012 - 06:46 PM, said:

I'm sorry that didn't work for you, I love an easy fix :)
If you can give more details about your setup it might help. I have setup windows FTP server on my laptop and that code works for me (windows 7, PHP 5.3). Try filezilla like Atli said and post back.
ENJOY:)

used filezilla an dit worked thnx man
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1