search
Homephp教程php手册Image upload without refreshing implemented by thinkphp5+zyFile.js

thinkphp5+zyFile.js实现的图片无刷新上传
zyFile.js体更了一个很美观的上传页面,同时上传图片无需刷新,也进一步提升了用户体验。我在网上找了好多的无刷新上传的插件,感觉这个还挺不错的,就像大家推荐这一款。
ps : zyFile.js 体供的代码存在一个bug,如果你直接下的网上的代码,把175行:file.name 改为 unescape(encodeURIComponent(file.name ))html页面代码:nbsp;html><br> <br> <br>     <meta> <br>     <title>html5批量上传文件</title> <br>     <!-- 引用控制层插件样式 --><br>     <link> <br>     <script></script><br> <br> <br> <h1 id="html-批量上传文件">html5批量上传文件</h1> <br> <div></div> <br> <script type="text/javascript"><br /> //Upload path<br /> var url = "{:url('index/upload')}";<br /> </script><br> <!-- Reference core layer plug-in --><br> <script src="/static/upload/core/zyFile.js"></script><br> <!-- Reference control layer plug-in --><br> <script src="/static/upload/control/js/zyUpload.js"></script><br> <script type="text/javascript"> <br /> $(function(){<br /> // Initialize plug-in<br /> $("#demo").zyUpload({<br /> Width: "650px", // width <br /> Height : "400px", // Width <br />                                                                                                                                                                                                                                                      having ’ s having ’ s ’ to having been passed to  --                                                                                                                                                                                                                                                                                                                                 url,                                                                                                                                                                                                                                                        dragDrop : true, // Is it possible to drag and upload files?                                                                                                                                                                                                                                          finishDel : false, false, // Whether to delete the preview after uploading the file <br /> ​​​​/* Externally obtained callback interface */<br />                                                                                                                                                                                                                                                             to console.info("The following files are currently selected:");<br /> console.info(files);<br /> console.info("Files not uploaded before:");<br /> console.info(allFiles);<br />          },<br /> onDelete: function(file, surplusFiles){                                                                                                                                                                                                                                        ; console.info("This file is currently deleted:");<br /> console.info(file);<br /> console.info("Currently remaining files:");<br /> console.info(surplusFiles);<br />         },<br /> onSuccess: function(file){ // Callback method for successful file upload<br /> console.info("This file was uploaded successfully:");<br /> console.info(file);<br />          },<br /> onFailure: function(file){ // Callback method for file upload failure<br /> console.info("This file failed to upload:");<br /> console.info(file);<br />          },<br /> onComplete: function(responseInfo){ // Callback method for upload completion<br /> console.info("File upload completed");<br /> console.info(responseInfo);<br />          }<br /> });<br /> });<br /> <br /> </script><br> <br> <br> index.php code:<?php <br /> namespace appindexcontroller;<br> <br> use thinkController;<br> <br> class Index extends Controller<br> {<br> Public function index()<br> {<br>           return $this->fetch();<br> }<br> <br> //Main method for processing upload<br> Public function upload()<br> {<br>           $file = request()->file('fileList');<br> ​​​​<br> $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');<br>            if($info){<br> // After successful upload, get upload information <br>                        // Output jpg<br> echo $info->getExtension();<br>                         // Output 42a79759f284b767dfcb2a0197904287.jpg<br> echo $info->getFilename(); <br>           }else{<br>                            // Failed to upload and got error message<br> echo $file->getError();<br>          }<br> ​​​​<br> }<br> }The effect is as follows:
Image upload without refreshing implemented by thinkphp5+zyFile.js
Image upload without refreshing implemented by thinkphp5+zyFile.js

Image upload without refreshing implemented by thinkphp5+zyFile.js qiniu.rar (3.85 MB Download: 2 times)

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!