Note that there are some explanatory texts on larger screens.

plurals
  1. PODownload a File and Upload it with PHP and AJAX
    primarykey
    data
    text
    <p>I am developing a web application that uses JQuery AJAX and PHP to upload some data into my database. </p> <p>One of the fields of the form to be submitted is an URL of a image (any address of the WEB). This image should be downloaded to my FTP server and then its new addrress would be inserted into the database.</p> <p>How can I download an image from any URL and upload it to my FTP server?</p> <p><strong>Form:</strong></p> <pre><code>&lt;form id="form-id" method="post" action="insert.php" charset=utf-8"&gt; &lt;input type="text" name="title" id="title"&gt; &lt;input type="text" name="image-url" id="image-url"&gt; &lt;input type="submit" name="submit" id="submit"&gt; &lt;/form&gt; </code></pre> <p><strong>JavaScript</strong></p> <pre><code>$("#submit").live("click", function(event){ event.preventDefault(); $.ajax({ type : "POST", url : "insert.php", data : { 'title': valueTitle, 'image': valueImage }, cache : false, success : function(html) { if (html == "success") { //... } else if (html == "ftp-error") { //... } else if (html == "sql-error") { //... } } }); }); </code></pre> <p><strong>insert.php</strong></p> <pre><code>$title = $_REQUEST['title']; $image = $_REQUEST['image']; $imageInMyServer = downloadImageFromURLAndUploadFTP($image); function downloadImageFromURLAndUploadFTP($image) { //that is what I want to know how to do. } //sql query with $title and $imageInMyServer </code></pre> <p><strong>Notes:</strong></p> <ul> <li>The file I want to download is not on my server. It is somewhere else in the Internet and I need to download it to my FTP server</li> <li>No. I cannot use the first external URL in my SQL Query </li> </ul>
    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.
 

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