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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Path info for ftp uploads

Status
Not open for further replies.

daybase

Technical User
Joined
Dec 13, 2002
Messages
115
Location
GB
Struggling with ftp uploads - is it right to include path name of file to be uploaded? As in:

<?php
$ftp_server="$ftp_user_name="myname";
$ftp_user_pass="mypass";
$destination_file="test.txt";
$source_file="c:/php/test.txt";

etc. etc.

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
was kinda hoping for a bit more info. How do you identify which file is to be uploaded if you don't specify a path?
 
Sorry, I misunderstood your question -- I thought you were asking about the destination filename.

You probably can use a path in the source filename -- try it an find out.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
doesn't work so trying to track down wny - thought I'd start with the file to upload. All the other FTP stuff works except the upload so going wrong somewhere
 
If you can connect and download successfully but not upload, my first thought is that it's a permissions problem on the FTP server.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I thought that might be the case but I have no problem using other FTP options - clients such as cute or even direct via internet explorer. This is what makes me think it has something to do with identifying the file to be uploaded
 
Simplify your test environment. Put the file to be uploaded in the same directory as your script and use only the filename in $source_file.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Not sure I understand (probably me being dim) but the script is on the server and the source file is on my PC. THat's the very basis of my problem of course.
 
You're trying to use PHP's FTP functions to move a file from a client to the server? Unless you have an FTP server running on the client machine, you can't do that.

And even if you do, all FTP commands are relative to the machine giving the commands. You won't be able to put the file -- you have to get it.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Lost me now - PHP manual entry for ftp_put() states

"Uploads a file to the FTP server (PHP 3>= 3.0.13, PHP 4 )
bool ftp_put ( resource ftp_stream, string remote_file, string local_file, int mode [, int startpos] )"

"ftp_put() stores LOCAL_FILE on the FTP server, as remote_file. The transfer mode specified must be either FTP_ASCII or FTP_BINARY. "

But as I always open to help - here's my problem:

I have a file called "c:\test\test.txt" and I want it uploaded to
My FTP connection is fine
so please give me the line of code which will solve my problems be it

ftp_get($conn_id....... or ftp_put($conn_id........

Put me out of my misery and be a hero forever!
 
There are a couple of things you must keep in mind:

First, the operative phrase in the description of ftp_put() is "to the FTP server". ftp_put() requires the action of an FTP server at the other end of the connection.

Second, PHP runs on the web server, not the client machine. So if you are putting a file from the server, the file transmission direction is away from the server, not toward it.

Again, if you have an FTP server running on the client machine, you could write a PHP script that will fetch a file from the client machine. But since you want the file to go to the server, you'd have to use ftp_get().

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
There are two threads going for this one, I identifed that he is probably trying to ftp from his PC but in fact what his script is doing is on the server. I recal he didn't want to use http file upload, which is probabbly his only option.
I get the impression sometimes that people don't really understand the client-server model
 
True.

<facetious>
But if everyone understood the client/server model and if everyone understood the whole discontinuous request/response nature of web apps, it would get very boring in this forum.
</facetious>

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Oh Yes !! , but it makes you wonder what apps they are building !!
 
HEY GUYS - read the early posts! I never claimed any expertise in this field which is why I asked for help! But hey, as you managed to work out that I'm trying to FTP from my PC to the server then you are experts - well done!

Usually users of this forum are patient courteous and helpful and I have received great assistance in the past. Frankly I find your comments un-necessary - if you can't or won't assist me then fine but please refrain from mocking.

I'm not fortunate enough to be able to take formal courses in such things so have to work 'em out for myself with the aid of books and the manual. No books I've discovered yet cover FTP and the PHP manual is vague - my code is lifted directly from the manual with only the variables changed and as there is no mention of where the script should be run from I assumed rightly or wrongly that it would be on the server as are my very successful PHP SQL and upload scripts. As the script won't work and I can't figure out why I thought I'd ask for help.
 
daybase:
There are a couple of things you should be aware of before you get your knickers in a twist.

First is my use of the "<facetious>...</facetious>" pseudo-tags in my posts. Yourdictionary.com defines "facetious" as "playfully jocular, humorous", which is the spirit in which intend for such a post to be interpreted.

Second is the fact that ingresman and I weren't talking about you in specific but rather about inexperienced users in general.



The fact that you lack theoretical knowledge of client/server architecture is no one's fault but your own. You're using this site via the internet, the single greatest compendium of human knowledge yet devised by our species.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
sleipnir
I've been wondering for as while if you're from the UK or the USA. The word "knickers" in your post certainly confirms the former!
Cheers mate!
 
smashing:
Nope -- born and raised in the southern U.S.

I use that idiom for two reasons:[ol][li]to make people wonder where I'm from and[/li][li]because I think "don't get your knickers in a twist" just sounds better than "don't get your panties in a wad"[/li][/ol]

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top