尝试使用jQuery为Zend框架找到一个AJAX文件上传解决方案

时间:2022-09-21 03:20:12

I'm trying to create an "upload file, and email as an attachment" form where the file starts uploading after it has been selected (like Gmail), before sending the email. I would also like to implement a progress bar to show the status of the upload.

我正在尝试创建一个“上传文件,和电子邮件作为附件”表单,在发送邮件之前,文件开始上传(如Gmail)。我还想实现一个进度条来显示上传的状态。

There should be all sorts of examples out there, but I just can't find them!

应该有各种各样的例子,但我就是找不到!

Do you know of any examples, or tutorials, plugins, helpers, or have you done this yourself and would like to share some code samples?

您是否知道任何示例、教程、插件、助手,或者您自己完成了这个任务,并希望共享一些代码示例?

Thanks!

谢谢!

7 个解决方案

#1


7  

Have a look at

看一看

There is also an example of integrating fancyupload with Zend Framework: although fancyupload is based on mootools, you can learn from what's explained.

还有一个集成fancyupload和Zend框架的例子:尽管fancyupload是基于mootools的,但您可以从解释的内容中学习。

Note: as fancyupload, uploadify uses flash. However, it degrades when flash is not available.

注意:作为fancyupload, uploadify使用flash。但是,当flash不可用时,它会降级。

#2


4  

Try using the jQuery form plugin, which has support for ajax uploading, examples can be found on the link provided. Zend Framework has a jQuery helper.

请尝试使用jQuery表单插件,该插件支持ajax上传,示例可以在提供的链接中找到。Zend Framework有一个jQuery助手。

#3


3  

As someone else suggested, Jquery has the plugin you need.

正如其他人所说,Jquery提供了您需要的插件。

A simple iframe will do the trick, and you'll need APC for the progress bar.

一个简单的iframe就可以做到这一点,您将需要APC作为进度条。

This is an 'heavy-tested' solution, for example the cms Drupal use it (dont know if with jquery, but im sure about the iframe and APC).

这是一个“经过严格测试的”解决方案,例如,cms Drupal使用它(不知道是否使用jquery,但我对iframe和APC很确定)。

Some tutorial:

一些教程:

Creating an Upload Progress Bar in PHP with APC

使用APC在PHP中创建一个上传进度条

Creating an Upload Progress Bar in PHP with APC: js/Ajax part in page 4

在PHP中使用APC: js/Ajax部分创建一个上传进度条

Upload con progress bar per APC + jQuery (italian language)

每个APC + jQuery上传con进度条(意大利语)

Upload progress bar with PHP5, APC and jQuery

使用PHP5、APC和jQuery上传进度条

HOWTO: PHP and jQuery upload progress bar

如何:PHP和jQuery上传进度条

Asynchronous file upload with AJAX progress bar in PHP

使用PHP中的AJAX进度条进行异步文件上传

Zend Framework: Documentation (Chapter 21.1.5. Progress for file uploads)

Zend框架:文档(第21.1.5章)。文件上传进度)

EDIT:

编辑:

I wont post the code becose is useless; just follow one of the tutorial i've posted (the first one, for example) and you'll find all the code you need with a full explanation of waht the cose do (that is more important than the code itself, imho).

我不会张贴代码,因为这是无用的;只要遵循我所发布的教程(例如第一个教程),您就会找到您需要的所有代码,并对cose所做的事情进行完整的解释(这比代码本身更重要,imho)。

[OT]

(OT)

Stop this stupid down/up votes war. We are not here to win stupid reputation, but to help each other in programming skill, right?

停止这种愚蠢的投票战争。我们来这里不是为了赢得愚蠢的名声,而是为了在编程技能上互相帮助,对吗?

I didnt downvote all whom suggested flash solution, just the andrew answer becose was kindly uncorrect and not a usefull analysis of the swf 'issue'.

我并没有对所有建议flash解决方案的人投反对票,只是安德鲁的回答有点不正确,没有对swf“问题”进行有益的分析。

The point is not that i dont like flash, but that flash is good (indispensable) for other kind of issues (video, music, etc..) but NOT a reliable solution for handling file uploads, things that can be easly done by Javascript and php itself (with APC, if you cant use APC on your server, then go with 'flash solution').

重点不在于我不喜欢闪光灯,但是,flash是好的(不可缺少的)其他类型的问题(视频、音乐等),但不是一个可靠的解决方案来处理文件上传,事情可以易通过Javascript和php本身(APC,如果你不能使用APC在您的服务器上,然后用“闪电解决方案”)。

With swf object, you just have to hope that the 'api' to handle it fulfill all you needs, else.. do they give you the source (.fla) file? do you have a license of adobe flash, and the knowledges to edit it? Are you ready to do taht everytime your fancy upload need even the simplier modification? You agree with me that find help for js or php is easyest than finding help for flash?

对于swf对象,您只需希望“api”来处理它,以满足您的所有需求,否则……他们会给你源文件(.fla)吗?你有adobe flash的许可证吗?你有编辑它的知识吗?你准备好每次你的花哨的上传都需要简单的修改吗?你同意我的看法,为js或php找到帮助比为flash找到帮助容易吗?

Thats why i don like the flash solution for this kind of issues.

这就是为什么我不喜欢这种问题的flash解决方案。

Then, feel free to keep you downvote on me, im here to learn not to gain silly rep point.

那么,请尽管对我投反对票吧,我在这里是要学会不要获得愚蠢的分数。

[/OT]

[/ OT]

#4


2  

I suggest you uploadify.com with jquery. The example is on the site. You can use this jquery plugin and store the file into the DB (maybe a temporany table). When the user will send the email you will fetch the files, attach it and delete it from the database.

我建议你使用jquery的uploadify.com。这个例子在网站上。您可以使用这个jquery插件将文件存储到DB中(可能是一个临时表)。当用户发送电子邮件时,您将获取文件,附加它并从数据库中删除它。

PS: if you have some sessions problems take this: zend framework losing session

PS:如果你有一些会话问题,可以这样做:zend framework失去会话

#5


0  

Have you looked at http://digitarald.de/project/fancyupload/ ? Seems to satisfy your requirements.

你看过http://digitard.de/project/fancyupload/了吗?似乎符合你的要求。

#6


0  

SWFUpload looks promising:

SWFUpload看起来承诺:

Pros:

  • Upload multiple files at once by ctrl/shift-selecting in dialog
  • 在对话框中按ctrl/shift选择一次上传多个文件
  • Javascript callbacks on all events
  • 所有事件的Javascript回调
  • Get file information before upload starts
  • 在上传开始前获取文件信息
  • Style upload elements with XHTML and css
  • 使用XHTML和css样式化上传元素
  • Display information while files are uploading using HTML
  • 在使用HTML上传文件时显示信息
  • No page reloads necessary
  • 没有必要页面重新加载
  • Works on all platforms/browsers that has Flash support.
  • 适用于所有支持Flash的平台/浏览器。
  • Degrades gracefully to normal HTML upload form if Flash or javascript is unavailable
  • 如果Flash或javascript不可用,则优雅地降级为普通的HTML上传表单
  • Control filesize before upload starts
  • 在上载之前控制文件尺寸。
  • Only display chosen filetypes in dialog
  • 在对话框中只显示选定的文件类型
  • Queue uploads, remove/add files before starting upload
  • 排队上载,删除/添加文件之前,开始上载

There's even a SWFUpload jQuery Plugin to make working with SWFUpload even easier, and a tutorial on How to use the SWFUpload jQuery Plugin to do Multiple File Upload with Progress Bar

甚至还有一个SWFUpload jQuery插件可以让使用SWFUpload更加容易,还有一个关于如何使用SWFUpload jQuery插件来使用进度条进行多文件上传的教程

Cons:

Requires Flash. =/

需要Flash。= /

Also, according to this blog post:

同样,根据这篇博文:

One issue many people run into when using SWFUpload with Zend Framewok is that sessions are often lost in the upload process.

许多人在使用带Zend Framewok的SWFUpload时遇到的一个问题是,在上传过程中经常丢失会话。

But the author offers a solution to lost sessions when using SWFUpload and the Zend Framework. Here also is a Stack Overflow solution to lost sessions when using SWFUpload and the Zend Framework.

但是作者在使用SWFUpload和Zend框架时为丢失的会话提供了一个解决方案。在使用SWFUpload和Zend框架时,这里还有一个堆栈溢出解决方案来处理丢失的会话。

#7


0  

Just a very important note - when using Flash uploaders, the file mime type will not be passed to the server and all files will be application/octet-stream - meaning you need to utilize other methods to find the real type... maybe an exe file was uploaded!

一个非常重要的注意事项——当使用Flash上传器时,文件mime类型不会被传递给服务器,所有的文件都是应用程序/八进制流——这意味着您需要使用其他方法来查找真正的类型……可能上传了exe文件!

#1


7  

Have a look at

看一看

There is also an example of integrating fancyupload with Zend Framework: although fancyupload is based on mootools, you can learn from what's explained.

还有一个集成fancyupload和Zend框架的例子:尽管fancyupload是基于mootools的,但您可以从解释的内容中学习。

Note: as fancyupload, uploadify uses flash. However, it degrades when flash is not available.

注意:作为fancyupload, uploadify使用flash。但是,当flash不可用时,它会降级。

#2


4  

Try using the jQuery form plugin, which has support for ajax uploading, examples can be found on the link provided. Zend Framework has a jQuery helper.

请尝试使用jQuery表单插件,该插件支持ajax上传,示例可以在提供的链接中找到。Zend Framework有一个jQuery助手。

#3


3  

As someone else suggested, Jquery has the plugin you need.

正如其他人所说,Jquery提供了您需要的插件。

A simple iframe will do the trick, and you'll need APC for the progress bar.

一个简单的iframe就可以做到这一点,您将需要APC作为进度条。

This is an 'heavy-tested' solution, for example the cms Drupal use it (dont know if with jquery, but im sure about the iframe and APC).

这是一个“经过严格测试的”解决方案,例如,cms Drupal使用它(不知道是否使用jquery,但我对iframe和APC很确定)。

Some tutorial:

一些教程:

Creating an Upload Progress Bar in PHP with APC

使用APC在PHP中创建一个上传进度条

Creating an Upload Progress Bar in PHP with APC: js/Ajax part in page 4

在PHP中使用APC: js/Ajax部分创建一个上传进度条

Upload con progress bar per APC + jQuery (italian language)

每个APC + jQuery上传con进度条(意大利语)

Upload progress bar with PHP5, APC and jQuery

使用PHP5、APC和jQuery上传进度条

HOWTO: PHP and jQuery upload progress bar

如何:PHP和jQuery上传进度条

Asynchronous file upload with AJAX progress bar in PHP

使用PHP中的AJAX进度条进行异步文件上传

Zend Framework: Documentation (Chapter 21.1.5. Progress for file uploads)

Zend框架:文档(第21.1.5章)。文件上传进度)

EDIT:

编辑:

I wont post the code becose is useless; just follow one of the tutorial i've posted (the first one, for example) and you'll find all the code you need with a full explanation of waht the cose do (that is more important than the code itself, imho).

我不会张贴代码,因为这是无用的;只要遵循我所发布的教程(例如第一个教程),您就会找到您需要的所有代码,并对cose所做的事情进行完整的解释(这比代码本身更重要,imho)。

[OT]

(OT)

Stop this stupid down/up votes war. We are not here to win stupid reputation, but to help each other in programming skill, right?

停止这种愚蠢的投票战争。我们来这里不是为了赢得愚蠢的名声,而是为了在编程技能上互相帮助,对吗?

I didnt downvote all whom suggested flash solution, just the andrew answer becose was kindly uncorrect and not a usefull analysis of the swf 'issue'.

我并没有对所有建议flash解决方案的人投反对票,只是安德鲁的回答有点不正确,没有对swf“问题”进行有益的分析。

The point is not that i dont like flash, but that flash is good (indispensable) for other kind of issues (video, music, etc..) but NOT a reliable solution for handling file uploads, things that can be easly done by Javascript and php itself (with APC, if you cant use APC on your server, then go with 'flash solution').

重点不在于我不喜欢闪光灯,但是,flash是好的(不可缺少的)其他类型的问题(视频、音乐等),但不是一个可靠的解决方案来处理文件上传,事情可以易通过Javascript和php本身(APC,如果你不能使用APC在您的服务器上,然后用“闪电解决方案”)。

With swf object, you just have to hope that the 'api' to handle it fulfill all you needs, else.. do they give you the source (.fla) file? do you have a license of adobe flash, and the knowledges to edit it? Are you ready to do taht everytime your fancy upload need even the simplier modification? You agree with me that find help for js or php is easyest than finding help for flash?

对于swf对象,您只需希望“api”来处理它,以满足您的所有需求,否则……他们会给你源文件(.fla)吗?你有adobe flash的许可证吗?你有编辑它的知识吗?你准备好每次你的花哨的上传都需要简单的修改吗?你同意我的看法,为js或php找到帮助比为flash找到帮助容易吗?

Thats why i don like the flash solution for this kind of issues.

这就是为什么我不喜欢这种问题的flash解决方案。

Then, feel free to keep you downvote on me, im here to learn not to gain silly rep point.

那么,请尽管对我投反对票吧,我在这里是要学会不要获得愚蠢的分数。

[/OT]

[/ OT]

#4


2  

I suggest you uploadify.com with jquery. The example is on the site. You can use this jquery plugin and store the file into the DB (maybe a temporany table). When the user will send the email you will fetch the files, attach it and delete it from the database.

我建议你使用jquery的uploadify.com。这个例子在网站上。您可以使用这个jquery插件将文件存储到DB中(可能是一个临时表)。当用户发送电子邮件时,您将获取文件,附加它并从数据库中删除它。

PS: if you have some sessions problems take this: zend framework losing session

PS:如果你有一些会话问题,可以这样做:zend framework失去会话

#5


0  

Have you looked at http://digitarald.de/project/fancyupload/ ? Seems to satisfy your requirements.

你看过http://digitard.de/project/fancyupload/了吗?似乎符合你的要求。

#6


0  

SWFUpload looks promising:

SWFUpload看起来承诺:

Pros:

  • Upload multiple files at once by ctrl/shift-selecting in dialog
  • 在对话框中按ctrl/shift选择一次上传多个文件
  • Javascript callbacks on all events
  • 所有事件的Javascript回调
  • Get file information before upload starts
  • 在上传开始前获取文件信息
  • Style upload elements with XHTML and css
  • 使用XHTML和css样式化上传元素
  • Display information while files are uploading using HTML
  • 在使用HTML上传文件时显示信息
  • No page reloads necessary
  • 没有必要页面重新加载
  • Works on all platforms/browsers that has Flash support.
  • 适用于所有支持Flash的平台/浏览器。
  • Degrades gracefully to normal HTML upload form if Flash or javascript is unavailable
  • 如果Flash或javascript不可用,则优雅地降级为普通的HTML上传表单
  • Control filesize before upload starts
  • 在上载之前控制文件尺寸。
  • Only display chosen filetypes in dialog
  • 在对话框中只显示选定的文件类型
  • Queue uploads, remove/add files before starting upload
  • 排队上载,删除/添加文件之前,开始上载

There's even a SWFUpload jQuery Plugin to make working with SWFUpload even easier, and a tutorial on How to use the SWFUpload jQuery Plugin to do Multiple File Upload with Progress Bar

甚至还有一个SWFUpload jQuery插件可以让使用SWFUpload更加容易,还有一个关于如何使用SWFUpload jQuery插件来使用进度条进行多文件上传的教程

Cons:

Requires Flash. =/

需要Flash。= /

Also, according to this blog post:

同样,根据这篇博文:

One issue many people run into when using SWFUpload with Zend Framewok is that sessions are often lost in the upload process.

许多人在使用带Zend Framewok的SWFUpload时遇到的一个问题是,在上传过程中经常丢失会话。

But the author offers a solution to lost sessions when using SWFUpload and the Zend Framework. Here also is a Stack Overflow solution to lost sessions when using SWFUpload and the Zend Framework.

但是作者在使用SWFUpload和Zend框架时为丢失的会话提供了一个解决方案。在使用SWFUpload和Zend框架时,这里还有一个堆栈溢出解决方案来处理丢失的会话。

#7


0  

Just a very important note - when using Flash uploaders, the file mime type will not be passed to the server and all files will be application/octet-stream - meaning you need to utilize other methods to find the real type... maybe an exe file was uploaded!

一个非常重要的注意事项——当使用Flash上传器时,文件mime类型不会被传递给服务器,所有的文件都是应用程序/八进制流——这意味着您需要使用其他方法来查找真正的类型……可能上传了exe文件!