Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // URL.PHP
- if($_POST["submit"]){
- $url = trim($_POST["url"]);
- if($url){
- $file = fopen($url,"rb");
- if($file){
- $valid_exts = array("jpg","jpeg","gif","png"); // default image only extensions
- $ext = end(explode(".",strtolower(basename($url))));
- if(in_array($ext,$valid_exts)){
- $rand = rand(10000,99999);
- $newfile = fopen("./images/" . $rand . basename($url), "wb"); // replace "downloads" with whatever directory you wish.
- if($newfile){
- while(!feof($file)){
- // Write the url file to the directory.
- 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.
- }
- }
- }
- }
- }
- }
- {
- echo "$url";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment