Skip to content
WJunction - Webmaster Forum

php remote upload code fix needed :)

Status
Not open for further replies.

speedbus

Established Member
134
2009
13
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.

About the author

S
Established Member · Joined
134
Messages
13
Reactions
18
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom