Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>An alternative solution if you do not have exec privileges is to use curl to grab the image, or you could use <code>file_get_contents()</code>, there are many ways, its just personal preference.</p> <p>Ive put together what your script may look like, im sure you can improve it.</p> <p><strong>insert.php</strong></p> <pre><code>&lt;?php if(isset($_POST['image']) &amp;&amp; isset($_POST['title'])){ if(substr($_POST['image'],0,4)=='http'){ $image = curlgetimage($_POST['image']); $info = pathinfo($_POST['image']); if(isset($info['extension']) &amp;&amp; ($info['extension']=='gif' || $info['extension']=='png' || $info['extension']=='jpg')){ $path='./temp/'.md5($_POST['image']).'.'.$info['extension']; file_put_contents($path,$image); if(ftp_put_image($path)===true){ //Do your database stuff, remember to escape.. unlink($path); echo 'Success'; }else{ echo 'ftp-fail'; } }else{ echo'File type not allowed'; } }else{ echo'Must start with http://'; } }else{ header('Location: http://www.example.com/'); } function ftp_put_image($file){ if(!file_exists($file)){return false;} $fp = fopen($file, 'r'); $conn_id = ftp_connect('ftp.yourhost.com'); //change $login_result = ftp_login($conn_id,'username','password'); //change $return=(ftp_fput($conn_id, $file, $fp, FTP_BINARY))?true:false; ftp_close($conn_id); fclose($fp); return $return; } function curlgetimage($url) { $header[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg'; $header[] = 'Connection: Keep-Alive'; $header[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERAGENT, 'YourSpiderBot/0.01 (Bla Bla Robot; http://www.example.com; spider@example.com)'); //change curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_REFERER, $url); curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($curl, CURLOPT_AUTOREFERER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 60); $return = curl_exec($curl); curl_close($curl); return $return; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload