PHP + JavaScript allows you to upload images without refreshing, phpjavascript
Html file code
<! -- Ajax File Upload starts -->
<Script type = "text/javascript" src = "/imageupload/jquery-1.10.2.min.js"> </script>
<Script type = "text/javascript" src = "/imageupload/layer. js"> </script>
<Script type = "text/javascript" src = "/imageupload/ajaxupload. js"> </script>
<! -- Ajax File Upload ends -->
<! -- Start the Upload File button list -->
<Input id = "requesturl" type = "hidden" value = "{: U ('admin/upload/uploadfile')}"/>
<Input id = "ajaxuploadfile" type = "file" onchange = "filechange ()"/>
<Input id = "filepathurl" type = "hidden" value = ""/>
<Input type = "button" value = "first" pathurl = "./Uploads/admin/trailer/" class = "uploadclass"/>
<Input type = "button" value = "second" pathurl = "./Uploads/admin/fdfdfd/" class = "uploadclass"/>
<Input type = "button" value = "third" pathurl = "./Uploads/admin/cdcdfd/" class = "uploadclass"/>
<! -- The Upload File button list ends -->
PHP file code
/**
* File Upload Method
*/
Public function uploadfile (){
// Upload a single file
$ Upload = new \ Think \ Upload (); // instantiate the upload class
$ Upload-> maxSize = 100000000; // sets the attachment upload size.
$ Upload-> exts = array ('jpg ', 'gif', 'png', 'jpeg '); // you can specify the attachment upload type.
$ Url = $ _ POST ['filepathurl'];
If (! File_exists ($ url )){
Mkdir (USD url, 0777, true );
}
$ Upload-> rootPath = $ url; // you can specify the root directory for uploading attachments.
// Upload a single object
$ Info = $ upload-> uploadOne ($ _ FILES ['postfilename']);
If (! $ Info ){
Echo json_encode (array ('bool '=> false, 'error' => $ upload-> getError ()));
} Else {
$ Path = $ info ['savepath']. $ info ['savename'];
Echo json_encode (array ('bool '=> true, 'path' => $ path ));
}
}