Automatically Import Image Into Form From Image Urls On The Web?
I'm using a form to upload wallpapers and we manually have to select a image file..I want to do this from a image URL ( image in the internet.. example- www.mysite.com/images/my.jp
Solution 1:
Change the input type from file to a text box. Then on the backend, use curl or something similar to download the image file that was input (if it exists).
if (isset($_POST['img'])) {
    $url = $_POST['img'];
    // Curl the URL
    $ch = curl_init ($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);
    curl_close ($ch);
    // Save it to disk
    $savePath = "/somewhere-on-your-disk/filename.jpg";
    $fp = fopen($savePath,'x');
    fwrite($fp, $result);
    fclose($fp);
}
Post a Comment for "Automatically Import Image Into Form From Image Urls On The Web?"