|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
Hello all,
I'm trying to use the file() function to retrieve the content of a file stored on a remote server, accessible only by FTP. So the line would be, Code:
$data = file("ftp://username:password@server.com/path") or die ("can't read file");
print_r($data);
And this works on some servers, but not all - either I get all the data, or I get the "can't read file" message. And unfortunately, it doesn't work on the server that I need it to be working on. And another weird thing is that fopen_wrappers are enabled on every server, so that's not the problem here. In fact, all servers will take an HTTP URL as parameter - but for some reason, one won't take the FTP url parameter. Safe mode is off, too, so it's not the issue either. Any idea why, and what I could do to get it to work? Thanks.
__________________
Encyclopaedia Metallum: The Metal Archives - the Ultimate Heavy Metal Archives! If it's not there, add it yourself. |
|
#2
|
||||
|
||||
|
Bump?
|
|
#3
|
|||
|
|||
|
I'm new at this, but do you need to log in to that server? The ones it's working on may allow anonymous access, but possible this one doesn't?
|
|
#4
|
||||
|
||||
|
Yes, I have to log in to that server, with a username and password. No anonymous access.
|
|
#5
|
|||
|
|||
|
I haven't had to open files from an FTP server yet. I've just downloaded them using php scripts. I'm sure someone here will be able to help you though.
|
|
#6
|
||||
|
||||
|
Well, I suppose an alternative would be to download the files on the local server, then read them locally, but that would probably take much longer.
![]() |
|
#7
|
||||
|
||||
|
So no one knows what could cause this?
|
|
#8
|
||||
|
||||
|
Quote:
The best way to do this is by using the FTP Function then reading the file this way it would save you lots of trouble, btw this way wont take long all you are doing is getting the file and reading of it.. i think the way you are doing it will take longer is the connection is keeped open
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev |
|
#9
|
|||||
|
|||||
|
Quote:
I know of the FTP function, but I don't see how it would help me. How do you READ a file's content with the FTP functions? I would have to first download (ftp_get()) the file, and then read it (again with file()) anyway. Here is what it says at the very top of the page you linked: Quote:
But I guess that's impossible for this server. Looking at the ftp:// wrapper page, it says here: Quote:
But that "server", would it be the FTP that I connect TO, or the server FROM which I connect? If it's the first case, it cannot explain why I can read the file from some servers and not others. ![]() Last edited by Morrigan : March 3rd, 2004 at 11:36 AM. |
|
#10
|
||||
|
||||
|
I have a script similar to something like this.. this is why i said to do it this way, you would have to download it and open it this way.. but its faster and better cause your not keeping any connection alive,.. if you dont know how to do it properly it can be a security hazard.. anyways to me php is not meant to do any server connections.. even if its there ( just my opn )
|
|
#11
|
||||
|
||||
|
Ok, well I guess I have no choice. Don't worry, I have no problems doing this way. As for your last comment, well I just happen to have no choice in the matter. :\
Thanks for the advice. |
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > file() doesn't take FTP URLs? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|