Can someone give some pointers regarding implementing pause and resume uploads using php and jquery ?
Regards,
There isn't a way to pause uploads with jQuery/PHP. Uploading a file relies on a POST request, which is either sent or isn't.
However, this plugin allows you to cancel them, along with some other very nice things (all without Flash).
If you want more options, go for Uploadify, which uses Flash.
we can use html5 to do this
http://hacks.mozilla.org/2011/04/resumeupload/
Related
Hey guys I'm trying to implement file upload on my site without refreshing the page. I don't want something like iFrame is there any other way to do this in ajax? I've tried though (USING Codeigniter & ajax but it outputs "You have not uploaded anything"). I've read certain pages like this one but I couldn't seem to implement it properly. Any suggestions guys? I read almost all suggestions posted here using jquery ajax but they are all not good. I just want pure jquery ajax nothing else.
If its not possible, iframe could do please share some examples. :)
Note: This is only good for one upload at a time. No multiples.
Instead of reinventing a whole thing from a scratch, I would use one of the file upload components.
Plupload - has UI, integrates nicely with jQuery. Depending on browser can use HTML5, Flash, Silverlight or HTML4
Swfupload
Uploadify
there is no AJAX file upload. Its all iFrame behind the curtain when it comes to file upload. The example link you gave does not do any magic but it uses hidden iFrame.
Many Answers can be found here: How can I upload files asynchronously?
This question may be a duplicate to the above
Ref: "There's various ready-made plugins on doing file upload on jquery.
Doing this kind of uploading hacks is not an enjoyable experience, so people enjoy using ready-made solutions.
Here's few:
http://www.phpletter.com/Demo/AjaxFileUpload-Demo
http://www.fyneworks.com/jquery/multiple-file-upload
Ajax File Upload Plugin
Multiple File Upload Plugin
You can search more from jquery's plugin -site."
From pure ajax it is not possible, you can use this ajax form plugin and it will be handle all things (create iframe automatically for input type file)
I have tried many, many plugins for a project in the past, and I came to the conclusion that I liked none of them. Well, except this one: jQuery-file-upload
In my experience this is easily the best plugin out there for handling file upload.
According to my knowledge there has to be a server side programming language such as php.
Try this out.
http://valums.com/ajax-upload/
I'm looking for free php and jquery(would be nice) upload script which I could
include in my webpage.
It must be able to upload multiple files, and make a
link for them.. as in mysite.com/randomstuff with a list of files
or if I upload one file, then it will redirect to hotlink and then people
wont have to click anything.
It must have easy way to upload files without logging in
so that when I upload I could just give the link to my clients
or friends so that they could download some support files, fixes, etc.
Thanks!
Have a look at this:
http://www.uploadify.com/
It is easy to use jquery and php uploading method. you can upload multiple files at a time.
Hope this helps.
For simple uploads (inc multiple files/good interface), this is what you need: http://www.uploadify.com/
However, it won't do all the url stuff for you. There may be another decent plugin for that. Or you could try some, you know, coding.
You can use a file upload script like the ones mentioned before, but I found that http://www.plupload.com/ is very nice to use.
Anyway, you will still need to code some php to make it work the way you want.
what is the best way to build an upload widget that can handle large files
is there a great jquery plugin for this?
I'd really love to have a progress bar without having to depend on flash
would need to use php for the backend
Take a look at Plupload.
It can't be done without patching PHP or using a combination of PHP and (perl or something else).
See:
http://pdoru.from.ro/
and
http://www.raditha.com/php/progress.php
I think what you're looking for is Uploadify.
Check out Blue Imp! Very nice interface and jQuery branch too!
APC allows to monitor file uploads from PHP http://www.phpriot.com/articles/php-ajax-file-uploads
You can code by yourselve the script that handles large uploads. You need html5 to slice in pieces the file and then upload them, and implode all the parts in the php server.
I have write how to do that in my blog
http://apuntes.alexmoleiro.com/2013/07/subir-archivos-grandes-de-100-mb-hasta.html
It is spanish but the you are going to understand everything just reading the code.
Hope it will be useful for you and for everyone that wants to upload big files without using widgets that really don't do exactly what we want.
I was trying to upload a photo on facebook using a browser with no flash, and could see that it didn't work.
I am pretty confident in handling files and related issues using Php and have done some sites allowing users to upload and manage files (images, docs etc). But I never thought about the above flash approach. I googled a bit and saw that there are few scripts available on which I can look how it works using flash.
But my questions are, when I should decide to use flash for user uploads. What are the advantages of using this approach? or disadvantages?
Thanks
It isn't a choice between Flash and PHP. You need something on the client to send the data and something on the server to receive it.
Ask yourself the following question:
Does Flash offer anything useful for my project?
The obvious things it lets you do are having a nice UI for selecting multiple files at once, and a simple method for seeing the progress of uploads.
If you decide that it does offer features, then implement it using progressive enhancement. Flickr is an example of this — with Flash you get the fancy uploader, without it you still get a series of regular file inputs. They aren't as nice to use, but they are functional and what would have been used if Flash wasn't an option in the first place
Depends on your audience: If you are pretty sure that your users have flash installed, there is nothing against it. It even gives some neat advantages, like:
Upload of multiple files at once
Progress bar while uploading
Instant preview of uploaded media
etc.
Well, with flash, the obvious letdown is that it will only work when a user has flash (although, you could display something in its place if they didn't). If your a flash programmer and comfortable with flash, I can see how it would be better. You could generate a file list, multiple uploads ect. I would say it's just an alternative to JavaScript for providing interactivity and allowing users to upload content dynamically.
when I should decide to use flash for
user uploads.
use it when the whole website is flash, but that is not professional and you can't count a lot on flash security, while you can write/use a lot of classes for hardening and checking files uploaded by php scripts..
on the other hand, some people like flash upload for progress bars, but you can do such stuff with php and jquery. for example check uplodify
Correction
I don't have flash support on my current browser so when watching uploadify demos I only see the fallback, thanks to soulmerge for making this clear
Does anyone know of any methods to create a file upload progress bar in PHP? I have often heard that it's impossible.
I have one idea, but not sure if it would work: have a normal file upload, but instead submit to an iframe. When this is submitted, store the file information (size and temp location) in the session. At the same time, start an AJAX call to every say 10 seconds to check the size of the file compared to the size stored in the session. This would return the size to the AJAX and then a progress bar would be sized and maybe display the uploaded size to the user.
Thoughts?
You're pretty much figured out how to do it. The main problem is you usually don't have access to the size of the uploaded file until it's done uploading.
There are workarounds for this:
Enabling APC, you to access this information if you include a field called "APC_UPLOAD_PROGRESS" and use apc_fetch() for retrieving a cache entry with the status.
There's also a plugin called uploadprogress but it's not very well documented and doesn't work on Windows (last I checked anyway).
An alternative is to use Flash for doing it. See scripts like FancyUpload.
Before APC came along I had to write a CGI script in C that wrote information to a text file. APC seems like a much better way to do it now though.
Hope this helps.
So far, the most common way of doing this is SWFUpload: http://www.swfupload.org/
However, it is possible with pure PHP, just very difficult and very experimental. I'll see if I can find the link.
Edit:
According to comments on php.net, as of 5.2 there is a hook to handle upload progress. http://us.php.net/features.file-upload#71564
More explanation:
http://www.dinke.net/blog/2006/11/04/php-52-upload-progress-meter/en/
http://blog.liip.ch/archive/2006/09/10/upload-progress-meter-extension-for-php-5-2.html
Rasmus' Example:
http://progphp.com/progress.phps
You can try YUI or Prototype or JQuery
From PHP 5.4 it is in session extension: http://php.net//manual/pl/session.upload-progress.php
In pure PHP, you are correct: it's not possible.
If you AJAX-ify this, then you could do what you're describing. The only progress meters I've ever seen are in Javascript or Flash, though I imagine Silverlight could do it also.
"Old school", but a PHP + Perl technique: http://www.raditha.com/php/progress.php
In my opinion, the best / easiest solution is to build a small flash widget, that consists of an 'Upload' button and a progress bar. Flash gives you very detailed feedback on how much data has been uploaded so far, and you can build a nice progress bar based on that. Doesn't require inefficient polling of the server, and in fact doesn't require any changes at all to your server code. Google for 'flash uploader' and you'll find many people have already written these widgets and are happy to sell them to you for a buck.
I'd recommend looking at SWFUpload to accomplish what you want. It's fairly flexible and supports queueing of files, so you could even handle multi-file uploads.
You will definately want to go with digitgerald's FancyUpload. It's Mootools & swfuplaod based, and it sports a nice queue with statusses, progress, eta etc. It's really the slickest method i've seen for uploading files. For my personal use case ivé used it to let the client select 1.2 gb of PDF files and upload them. Newer ones get renamed and versioned automatically, same are skipped, etc.