Home >Backend Development >PHP Tutorial >ajax file upload_PHP tutorial

ajax file upload_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:07:391120browse

This is an ajax image upload function that was used during application development yesterday. The method is very simple, which is to use js to upload the file to the iframe directly. If the file is uploaded successfully, it will return 1, and then use js to determine whether to upload it. If successful, the image will be output and the preview will be displayed.

This is an ajax image upload function that was used during application development yesterday. The method is very simple, which is to use js to upload the file to the iframe directly. If the file is uploaded successfully, it will return 1, and then use js to determine whether to upload it. If successful, the image will be output and the preview will be displayed.





ajax file upload





                                                                                      
         

​  

(Can upload gif, jpg, png)






upload.php

$destination_path = '../../upfile/jianjulogo/';//getcwd().directory_separator;

$result = 0;

$target_path = $destination_path . basename( $_files['myfile']['name']);

if(@move_uploaded_file($_files['myfile']['tmp_name'], $target_path)) {
$result = 1;
}
echo $target_path;
sleep(1);


?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630174.htmlTechArticleThis is an ajax image upload function used in application development yesterday. The method is very simple: The file is uploaded directly to the iframe using js. If the file is successfully uploaded, 1 is returned, and then js is used to determine...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn