secure and efficient file uploader - php

I am looking for a decent file uploader. I'm using django, but while i don't NEED a django file uploader, python is preferable. php would also be fine.
can anyone point me in the direction of a good file uploader which is secure and efficient?
EDIT: I need the server-side handler of file uploads.

Agree with jeerose: Uploadify is a nice app.
I've made a simple Django wrapper for it as well if you're interested: django-uploadify. It basically gives you a template tag which renders uploadify and fires a Django signal whenever a file is received.
How you implement the 'handler' you mentioned above is simply a matter of subscribing to the signal and then doing whatever you wish with the incoming data. (the wiki includes an example of creating a new File Model if that's the kind of thing you're looking for)

I'm using uploadify which is an upload plugin for jQuery with a flash progress bar. I use some basic php for the upload script. It can be made as secure as you need with a little investigating the forum.

Related

PHP: upload files (vids) directly to S3

I'm looking for examples (maybe on Github, blog, or elsewhere) that demonstrate how to upload files (videos) directly from a php http post form to AWS S3. The main requirement is to see the progress of the upload in action and trigger a response when complete (without reloading the page). jQuery File Upload Plugin could be a good solution, do you know of any code examples that do this? The files (videos) will be up to 1gb in size, so propose a different method if you think this won't work well.
You have checked this out, right?
Sadly, there's no progress involved by default. Probably you should do it yourself using AWS serverside API and ajax polling (or websockets), which would add workload for your server, though.
Here is a C# example of how to track the Multipart Upload Progress.
Otherwise you could go for a client-side approach with the Javascript SDK.

Plupload - doubts about security

http://www.plupload.com - "Allows you to upload files using HTML5 Gears, Silverlight, Flash, BrowserPlus or normal forms, providing some unique features such as upload progress, image resizing and chunked uploads." This is the uploader used in current WordPress v3.4.1 and the best one out there in my opinion.
It comes with upload.php file (full file: http://ideone.com/xbPUS).
I have doubts about its security: When I have upload.php on my server and even if I don't setup any Javascript for Plupload anyone is still able to relatively easy send request to upload.php file and upload anything, anytime... TRUE OR FALSE?
How do I prevent that?
It's not a security issue. Across the internet you can try to upload anything you want to servers (addresses) that support POST method. It's up to server-side software to accept or reject such upload - it's always been this way. Of course there can be some restrictions put onto who uploads what (using tokens, authorization etc), but that's up to you (as developer) to handle.
As to upload.php file from plupload, I think it's suppose to be just a quick and dirty example, that makes trying out plupload a little bit easier.
I think you want Wordpress to work with upload.php and not the other way arround. So if anyone would call upload.php directly it will fail. Can you set some specific information that will only be available from within your Wordpress functions. In upload.php you can ask for this information if not available it will stop. Hope this is what you need.

How can I create a file upload progress bar with PHP and jQuery?

How can I create a file upload progress bar with PHP and jQuery? Please don't refer me to Flash stuff like Uploadify. I want to create my own.
Just store and update the progress in server side session and use repeated ajaxical calls from the client side on to obtain the current progress from the server side session until it gets 100%. Long story short, here's a clear tutorial how to do it with PHP and jQuery: How to build an ajax progress bar with jQuery and PHP.
Then the server side part, you need at least PHP 5.2 for this with the PECL Uploadprogress extension. You can find here a blog about it: PECL Uploadprogress example. This comment of jazfresh on php.net is also helpful.
If you don't want to use an already prebuilt one like swfupload you'll have to get your action-script-fu ready and use the external interface api to make it talk with jQuery.
Basically you'll need to control how much data is sent in some time span. As you don't control your browser data transfer, neither how your browser read data from your file, you can't do that with plain Javascript.
You'll need some 3rd party control, like Silverlight, Flash or Java applets. Using them you'll have granted that filesystem access, so you can control how to read your source file. So, to build your progress bar, you just need to make several HTTP calls to your server application sending your source file in small pieces.
To get file(s) upload progress you should use Flash. A tutorial with more info can be found here. Note that this is using .NET though, not PHP.

Uploading a file to an external site with progress reporting

here is my situation:
I want to create an AJAX file-upload script, which will upload to an external site (ie: not the one the script is located in) and at the same time report the progress of the upload. How would I go about doing this? Note that the process must be secure.
If you are POSTing the file to another server there is no way to know the status of this upload since the upload is done between the users browser and the remote site.
If you have access to the script that handles file upload on the other site you could use Zend_File_Transfer and Zend_ProgressBar to fetch the information on the uplad progress from the other site and display it on your page.
Note: to use Zend_ProgressBar you need APC or uploadprogress extension.
There are two ways to do:
Using ajax and CGI
Using flash
The advantage of the flash method is that it does not require you to rewrite any server side scripts. This is especially good if you upload to a different server than yours. You do need to put a cross domain xml file on that server though.
The advantage of the ajax version is that it does not require your users to have flash installed.
There is no way to get the exact progress using ajax and php. Using php and ajax you can only know wheather the upload is in progress or finished. That is the reason why all ajax/php aplications have loading but no progress bar. If you explicitly want progress bar you should use a PERL CGI
Flash ( swfupload ) is probably the easiest. Vimeo.com uses swfupload to achieve this as well. Ihe only other method I know of involves php and APC which a tutorial of can be found at http://phpriot.com/articles/php-ajax-file-uploads.

Scan folder on local (user's) PC and upload all files(images) to web server

I wish my users could select a directory from their PC and upload all files from this directory, so they could upload whole album(directory) instead of uploading every single file separately.
I would like to ask you if this is somehow possible using PHP or JavaScript and without using any framework.
thank you
First of all, PHP can't do anything to the user's local computer. Since it never runs there (unless the user's computer is the server also).
JavaScript runs on the user's local computer but isn't setup to handle things like this.
Java and Flash runs on the user's computer and can be setup to do exactly this.
Look at SWFUpload. I highly recommend it.
And if you want Java, check out RadUpload. The lite edition is free.
A thing to note, what these Flash and Java solutions both do is accept a file selection from the user and then send that to a PHP script which does the actual uploading.
It would probably make more sense for them to upload a .zip containing multiple images - which is possible in PHP.
I do not think it is possible as you describe it. Create a small utility which they can run on their PC that will do the job. Also check out how Facebook upload image works. They upload dozens of images at the same time.
Not possible using purely php/javascript. However, take a look at http://www.element-it.com/JavaPowUpload.aspx, it is a java-based file uploader that allows you to completely hide the interface, and, if you wish, power the whole interface via javascript. However, it is not free, perhaps not suitable for a personal project.
This may not meet your requirement of Javascript, but if you wish you could build your uploader object as an activex object and use CURL to actually perform the upload or do it as a Java applet.
I had built a Java applet based uploader for a client and I found resources on line and used that as my base for building the uploader.
SWFUpload, as mentioned in one of the answers you received is a good one.

Categories