rhoula

Untitled

Sep 21st, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2. // URL.PHP
  3.  
  4. if($_POST["submit"]){
  5.  
  6. $url = trim($_POST["url"]);
  7.  
  8. if($url){
  9. $file = fopen($url,"rb");
  10. if($file){
  11.  
  12. $valid_exts = array("jpg","jpeg","gif","png"); // default image only extensions
  13. $ext = end(explode(".",strtolower(basename($url))));
  14. if(in_array($ext,$valid_exts)){
  15.  
  16. $rand = rand(10000,99999);
  17. $newfile = fopen("./images/" . $rand . basename($url), "wb"); // replace "downloads" with whatever directory you wish.
  18.  
  19. if($newfile){
  20. while(!feof($file)){
  21.  
  22. // Write the url file to the directory.
  23. fwrite($newfile,fread($file,1024 * 8),1024 * 8); // write the file to the new directory at a rate of 8kb/sec. until we reach the end.
  24.  
  25. }
  26. }
  27. }
  28. }
  29.  
  30. }
  31. }
  32. {
  33. echo "$url";
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment