Forum Moderators: coopster

Message Too Old, No Replies

FTP how to write the path

         

kknusa

11:25 pm on Jan 2, 2004 (gmt 0)

10+ Year Member



Hello all

My question, i have a form that gives me the path for the file to be uploaded that is it returns
C:\Documents and Settings\D\Desktop\file.jpg
now that i have the path i want to upload the file using FTP. I make the connection and everything works perfect in that area but my script doesn't upload. This is the part of script i'm having problem with i think.

... FTP Login code ...
$dest="temp.jpg";
$sourcefile= "C:\Documents and Settings\D\Desktop\file.jpg";
$upload=ftp_put($conn_id,$dest,$sourcefile,FTP_BINARY);
...

Is this the right way to put the paths?
thank you

NickCoons

12:58 am on Jan 3, 2004 (gmt 0)

10+ Year Member



I don't know if this is the problem, but it looks like it's a problem. I believe the backslashes in your path need to be escaped:

$sourcefile= "C:\\Documents and Settings\\D\\Desktop\\file.jpg";

kknusa

2:43 am on Jan 3, 2004 (gmt 0)

10+ Year Member



Thnks for the reply

I tried that but still doesn't work, I also changed directory permissions to 777 but still does not work.

I'm sure FTP is connecting cause i'm able to create directories using FTP functions, So i don't see problem other than the path?

bofe

6:23 am on Jan 3, 2004 (gmt 0)

10+ Year Member



If you're wanting to upload a file via a form don't need to use ftp_put.

ftp_put is for you to FTP a file on your server to another FTP site.

Check this for PHP Handling file uploads:
[us2.php.net...]

NickCoons

7:44 am on Jan 3, 2004 (gmt 0)

10+ Year Member



bofe has a good point. You use FTP functions in PHP to cause your website to act as a FTP *client* to connect to a remote FTP *server*.. they is not used to cause your machine to make an FTP connection to your web server.

kknusa

3:33 pm on Jan 3, 2004 (gmt 0)

10+ Year Member



Ok guys i see your point , and yes you are right bofe i have already looked at that option. But i was hoping i could do it with FTP.

So is the conclusion that a file transfer from the local computer to the remote webserver cannot be achieved by using FTP? or should the local computer have some kind of FTP server running.

THnks again

bofe

5:01 pm on Jan 3, 2004 (gmt 0)

10+ Year Member



Why do you need to do it with FTP?

If you want to pull a file from an end user and transfer it to your server following the link above is the way you're supposed to go.

ftp_put, like NickCoons said is for your SERVER to FTP into another FTP site.

A good example of this is the blogger service. If you don't have your blog hosted on their blogspot.com service, you can fill out your FTP information and have your blog published on your site.

The way this works is the user writes their post, it is stored on blogger's server, and the blogger program FTPs the files generated to the server you specify, updating your site.

kknusa

5:56 pm on Jan 3, 2004 (gmt 0)

10+ Year Member



You are right , thanks for the info