Home > Backend Development > PHP Tutorial > PHP+ajax image file asynchronous upload sample code

PHP+ajax image file asynchronous upload sample code

WBOY
Release: 2016-07-25 08:53:07
Original
1273 people have browsed it
  1. jQuery.extend({

  2. createUploadIframe: function(id, uri)
  3. {
  4. //create frame
  5. var frameId = 'jUploadFrame' + id;
  6. var iframeHtml = '
  • Copy the code

    index.js file:

    1. $(function(){
    2. $("#upload_file").change(function(){
    3. $("#uploadFrom").submit();
    4. });
    5. });
    6. function stopSend(str){
    7. var im="";
    8. $("#msg").append(im);
    9. }
    Copy code

    upload.php file:

    1. $file=$_FILES['upfile'];
    2. $name=rand(0,500000).dechex(rand(0,10000)).".jpg";
    3. move_uploaded_file ($file['tmp_name'],"upload/images/".$name);
    4. //Call the js function of the iframe parent window
    5. echo "
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template