Jump to content

How to transfer jpeg from remote server to my own?


egaertner

Recommended Posts

I'm trying to write a function that is passed an external url as a parameter (ex: www.remoteServer.com/image.jpg) and stores that file locally on my server, say in my working directory.

 

I've researched the topic for a solution, but I haven't found any that I believe will work with my server, which I am unable to change the parameters on. http://www.nutv.neu.edu/info.php

 

The two problematic sections that jump out at me are that curl_init is under disabled functions, and allow_url_fopen is turned off. Additionally, I can only connect to the server via SFTP, not FTP.

 

Any solutions for this simple task that I'm overlooking, given what I have to work with?

Link to comment
Share on other sites

That gives me a zero byte file unfortunately. Is it perhaps due to permissions? They're set at 0775 so others have no write access, if I change this up to 0777 the pages refuse to load, so I presume thats a security measure of the server host.

 

I also tried to echo $file and got no data output at all, so perhaps its failing at file_get_contents.

Link to comment
Share on other sites

You could simply make the file available or available upon secure entry on your current restricted server, like pass a password through the URI through HTTP GET, and then it will give access to your files you wish to transfer

 

THEN, on your remote server (if you can run scripts that is..) you can simply download the files you made available. You can even call such a downloading script FROM your restricted server, making you never have to touch your remote server, and have your restricted server do all the work, giving u the same effect as you originally wanted. (how everything is controlled by restricted server)

 

So instead of uploading files from restricted server to remote server, you can download file from restricted server to remote server.

Link to comment
Share on other sites

ucffool: Yes, allow_url_fopen is disabled, which is what's making this difficult

 

dsaba: I don't follow exactly. The remote server I'm trying to pull data from is essentially a black box, I don't have any control over it. I'm currently hot linking images from it, which I would like to stop doing for obvious reasons, so I'm trying to automate the process of taking the image and storing it on the local server, so I can simply link the image there. Between the various disabled functions my restricted server seems to have imposed, I can't determine any functions to do what I need.

Link to comment
Share on other sites

Look up the snoopy library.  It uses cURL to allow you to retrieve a remote file using a url.  You can do this with a picture using something like this:

 

include ('./snoopy.php');
$url = "http://some.domain.com/filename.jpg";
$snoopy = new Snoopy;
if(snoopy->fetch($url)) {
  $img = snoopy->results;
  imagepng($img, './filename.jpg');
  } else {
  echo "There was an error, the file was not retrieved.";
  }

 

I didn't test this and it was all from memory, but snoopy isn't too difficult and it works.

Link to comment
Share on other sites

Look up the snoopy library.  It uses cURL to allow you to retrieve a remote file using a url.  You can do this with a picture using something like this:

 

include ('./snoopy.php');
$url = "http://some.domain.com/filename.jpg";
$snoopy = new Snoopy;
if(snoopy->fetch($url)) {
  $img = snoopy->results;
  imagepng($img, './filename.jpg');
  } else {
  echo "There was an error, the file was not retrieved.";
  }

 

Unfortunately, looking through that source, it is dependent on fsockopen() to create the initial connection to do anything else. Since that function is disabled on my server, it won't work.

I didn't test this and it was all from memory, but snoopy isn't too difficult and it works.

Link to comment
Share on other sites

Read the initial post. CURL and url_fopen are both disabled.

 

From what I know, they have built php to not communicate with outside servers... so... I don't think it's possible. Maybe a local server that grabs and uploads for you (via ftp perhaps) and executes a remote script to update anything else needed on the server.

Link to comment
Share on other sites

Read the initial post. CURL and url_fopen are both disabled.

 

From what I know, they have built php to not communicate with outside servers... so... I don't think it's possible. Maybe a local server that grabs and uploads for you (via ftp perhaps) and executes a remote script to update anything else needed on the server.

 

Hacky, but not a bad idea, and something that certainly could work. Unless I sweet-talk to the IT gods into enabling one of those functions.

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.