简体   繁体   English

如何制作一个上传表单,该表单将在php中上传文件,并在jquery中显示结果?

[英]How do I make a upload form that will upload the file in php, and show result in jquery?

How do I make a upload form that will upload the file in php and I would like to make it jquery(with ajax) so that it returns a percentage too show the user that he is still uploading the file. 我如何制作一个上载表单,将用php上载文件,我想使其成为jquery(使用ajax),以便它返回一个百分比,也向用户显示他仍在上载文件。 Would like to do this with no installation libraries,IE APC,uploadprogress 想要在没有安装库,IE APC,上传进度的情况下执行此操作

Use flash uploader like Uploadify This is the most simple solution as it's jQuery enabled library which utilizes a tiny transparent 1 pixel flash. 使用像Uploadify这样的Flash上​​载器这是最简单的解决方案,因为它是jQuery启用的库,它使用了一个微小的透明1像素闪光灯。

Flash can provide you with a lot of options: filter file selection by extension, multiple uploads, upload progress :). Flash可以为您提供多种选择:按扩展名筛选文件,多次上传,上传进度:)。

You can't really do it in an elegant way with PHP/Ajax/jQuery only. 仅使用PHP / Ajax / jQuery,您不能真正以一种优雅的方式做到这一点。

Consider using java applet JumpLoader . 考虑使用Java小程序JumpLoader

If old browsers are'nt a concern, you can do this with HTML5's File API. 如果不需要使用旧的浏览器,则可以使用HTML5的File API来实现。

It's all very technical, and you would have to read up on it yourself, but here's an example page that accepts images for upload with HTML5 only, no iFrames or PHP : base64img.com 这都是非常技术性的,您必须自己阅读,但是这里有一个示例页面,该页面仅接受使用HTML5上传的图像,而不接受iFrame或PHP: base64img.com

Once the file is uploaded, the data can be sent to PHP with Ajax and stored or manipulated serverside, or you can use localstorage or if possible do what you need to do directly in javascript, depends on what exactly you intend to do with the file. 文件上传后,可以使用Ajax将数据发送到PHP并在服务器端进行存储或操作,或者您可以使用localstorage,或者在可能的情况下直接在javascript中需要执行的操作,取决于您打算对文件执行的操作。

The HTML5 File API has built in solutions for progressbars and a bunch of handlers for loading, start, complete etc. HTML5 File API内置了用于进度条的解决方案以及一堆用于加载,启动,完成等的处理程序。

If older browsers are a concern, you could have a PHP fallback or something similar. 如果需要使用较旧的浏览器,则可以使用PHP后备或类似的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM