Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>May be try this it will work.<a href="http://testingimage.webege.com/Test/fileUpload.php" rel="nofollow">Demo Link</a></p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Ajax file upload&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="upload.php" method="post" enctype="multipart/form-data" target="workFrame" &gt; &lt;input type="file" name="file" /&gt; &lt;input type="submit" /&gt; &lt;/form&gt; &lt;iframe id="workFrame" src="about:blank" style="display:none;"&gt;&lt;/iframe&gt; &lt;div id="image_disp"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; &lt;script src="http://code.jquery.com/jquery-1.8.1.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script&gt; $('form').on('submit', function () { //check if the form submission is valid, if so just let it submit //otherwise you could call `return false;` to stop the submission }); $('#workFrame').on('load', function () { $('#image_disp').html(''); //get the response from the server var response = $(this).contents().find('body').html(); $('#image_disp').html('&lt;img src="images/'+response+'"/&gt;'); //you can now access the server response in the `response` variable //this is the same as the success callback for a jQuery AJAX request }); </code></pre> <p></p> <p>Upload.php</p> <pre><code>&lt;?php if(isset($_FILES['file']) &amp;&amp; $_FILES['file'] != '') { if(isset($_FILES['file']['name']) &amp;&amp; $_FILES['file']['name'] != '') { $image_name = explode(".",$_FILES['file']['name']); $image_type = array_pop($image_name); move_uploaded_file($_FILES['file']['tmp_name'],'images/upload.'.$image_type); echo 'upload.'.$image_type; } } ?&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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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