By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

Copy a file from one server to another

P: 22
If the permissions are set to 777 of all files and all directories. Is there a possible way to do it without having to download it and upload it again? I don't expect this to work on PHP files. I'm thinking .exe files, etc...

I've tried using fopen() and fread() and also file_get_contents().
Neither of which worked to get the file, although, oddly, didn't return an error.

If anyone knows about this can you please let me know?

Thanks
~Tyler
Jul 18 '07 #1
Share this Question
Share on Google+
5 Replies


P: 22
I was going to edit my post and say that I don't have FTP access to this server. Although I want to use this to legally get a file and transfer it to my server without having to download and upload it. I've searched google and everywhere. Can't find a tutorial. Maybe there is a way to do it via CURL?
Jul 19 '07 #2

pbmods
Expert 5K+
P: 5,821
Heya, tscott.

What kinds of files are these? If they are PHP files, you won't be able to fetch them via cURL nor using file_get_contents() because the remote server will evaluate any scripts that you try to fetch via HTTP.
Jul 19 '07 #3

P: 22
I said they weren't PHP files, I meant for an example an *.exe file or a *.html file.

A file that any user could download and upload.
All I end up with is a blank file.

Is that possible.
Jul 19 '07 #4

pbmods
Expert 5K+
P: 5,821
Heya, Tyler.

Hm.

The easiest thing to do would be to download them and then upload them again. Not a whole lot of fun, but when's the last time you backed up all your server's files anyway?

In terms of "no error, no content", note that file_get_contents() and fread() generate errors of E_NOTICE severity when they encounter HTTP errors (e.g., 404 not found). Most developers turn off these errors because they are non-critical and generally annoying.


[EDIT: Though I never said that most developers SHOULD do this... nudge, nudge.]
Jul 22 '07 #5

kovik
Expert 100+
P: 1,044
Servers can control everything that you do while on the server. You may be downloading from a server that doesn't allow external referrers to access their content.

Try simply loading their file as a part of a page using cURL, and turn on the header display so you can see if you have access or not.
Jul 22 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.