php remote upload code fix needed :)

Status
Not open for further replies.

speedbus

Active Member
134
2009
13
20
Hey,
I used this code for remote upload of pics

Downloading of pics from remote server to my image host.

My Image Host :
Code:
www.imgair.net

The Script is here :
Code:
http://imgair.net/remote.php

It returns a HTTP Error 500 (Internal Server Error), while all the other pages on the same server load perfectly (htm, html and php pages)

Code:
<?php 
function remoteUpload($url) 
{ 
   $newfname = "images/".str_replace('%20',' ',basename($url)); 
   $file = @fopen ($url, "rb"); 
   if($file) 
   { 
      $newf = fopen ($newfname, "wb"); 
      if ($newf) 
      { 
         while(!feof($file)) 
         { 
            fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 ); 
         } 
         if ($file) 
            fclose($file); 

         if ($newf) 
            fclose($newf); 

         chmod($newfname,0755); 
         if(file_exists($newfname)) 
         { 
            //add the image to your database 
            //print the path of the image 
         } 
         else 
            error('There was an error uploading that image.'); 
      } 
      else 
         error("We're sorry, but there was a problem uploading that image. It probably has an incorrect extension."); 
      } 
   } 
} 
?>

if any one helps me out with this, i will surely put your name in the credits page on my site..

also , i wanted to know if the script displays the image link that has been uploaded.

Please help me out with this :)

Thanks,
SpeedBus
 
4 comments
When you get that 500 error normally a error log is created in the folder it is run or in the root folder.

Check and see if there is one to give us more information.
 
Status
Not open for further replies.
Back
Top