Laravel Progress bar for data upload - laravel

I am using laravel 5.1
I want to create a progress bar based on how long the file takes to upload.
I have multiple input fields and want to upload / get a progress bar on my submit button.
What would be the best (or good) approach of doing this.
I basically have a form and already upload some file in the database.
But I do not know how to create a upload progressbar based on this.

I think the best way is to use a library like this one:
https://github.com/zimt28/laravel-jquery-file-upload

I'd probably use something like Dropzone js
http://www.dropzonejs.com/
It would give you the added extra functionality of allowing you to drag and drop files into an upload area. Also allowing for multiple file uploads.

Related

Best practice for multiple (single) file uploads in JSF 2.2

Our JSF 2.2 web application may have the situation, that users have to fill in a formular where they have to upload multiple files.
Example
First Name: [ John ]
Last Name: [ Doe ]
Photo: [ choose File ] (no file chosen)
Passport: [ choose File ] (no file chosen)
I know that there is multiple upload forms like Primefaces but this doesn't fit to my requirement, since I want to know which file is either the photo or passport, and I need to validate the input, because the files are mandatory.
Option 1: Multiple single file uploads
The first option would be like in the example above. Just use multiple single <h:inputFile> tags.
Pros:
users select files when they are asked for
users know this kind of file uploads
Cons:
since there are more <h:inputFile> tags, every file upload will be processed during the form submit: so we might have to limit filesizes so that users won't run into problems
I did not try this: is it even possible to use multiple single file uploads in the same <h:form>?
Option 2: Upload in popup + callback
I have seen this sometimes and wondered why it was implemented that way. When you have to upload a file it opens a popup with a file upload. After the upload, the popup is closed and the form has selected the uploaded file.
Are there any hints/tutorials for this technique? Especially the between-window-communication is unclear for me.
Pros:
nearly the same as the standard way
Cons:
problems with popup-blockers
for this approach, fallback mechanics have to be implemented: what if the user cancels the form? when are uploaded files deleted, so that there are no garbage files?
Option 3: Upload in modal dialog + callback
To eliminate the popup blocker problem we could use a modal dialog for an upload. So we choose to upload a file, a new modal <p:dialog modal="true"/> opens and there inside the <h:inputFile> handles your upload.
I did try this and found out that AJAX uploads are not possible with <h:inputFile> or <p:inputFile mode="simple"> (can't find the source of BalusC's comment, but there is a similar one). My whole site got rerendered and my formular input was lost.
Pros:
nearly the same as the standard way
no problems with popup blockers
Cons:
even possible?
Option 4: "Upload Manager"
My last idea was to provide an upload manager. This is a view where users can see their uploaded files in a list/table and add files with a single <h:inputFile>, add descriptions, and so on. So the files are already in the system and get deleted after (say) 72 hours if they are not referenced.
Users then click on a link when they have to input a file, and choose the corresponding file from a list/table in a modal dialog. Therefore users have to upload their files first, before even filling a form, which is quite a pain, so it would be nice if they could also upload files in the modal dialog. (this would look like a view, where they have a single <h:inputFile> and a list of their already uploaded files). But there we have the same AJAX problem like in Option 3...
The only way I see to get around this, is to write something at the beginning of a form like:
For this form you need the following files in your upload manager:
- Photo
- Passport
Pros:
technically: good because it's always only one file in a submit (AJAX?)
no specific fallback mechanisms (except a 72hrs cronjob deleting unused files)
users can upload multiple files for the (say) next 20 forms - this is good in our web application
Cons:
users are not used to this technique
even possible?
Do you have any other ideas to handle with this situation? I can't be the only one with this.
Or are multiple file uploads like Primefaces good to configure for validations?
I hope you can help me out with this brainstorming

How to receive a file after drag and drop

I'm trying to build a web application that allows users to drag and drop a file from their desktop (like justbeamit.com) to an "icon" that represents another user, and so that the different user could receive it on the other side. I see that this is possible using the dropzone.js feature, but I want to know is how it's possible to link this with the receiving function so that the other user could download it simply after receiving a notification. I know it sounds complicated, but wish you guys could do good on me by providing knowledge on how to link the drag and drop functionality with a function that allows the other user to receive and download the file. Thanks!
If you are using MVC framework you can get the file from controller as body.request.body.dataParts.get

How to get data from grid and download them like .csv file in ExtJS 4.2

I have a Ext.grid.Panel and I fill it with store that is populated from database. And there is an export button. When the user click on the Export button, I want the data from grid should start downloading like .csv file
The best solution to creating any type of file (Excel, CSV, PDF, whatever) is going to be leveraging your application server to create and serve up the file for download. There are literally thousands of libraries across most of the popular server-side languages that can create just about any kind of file that you'd want to create.
So ultimately this has nothing to do with Ext JS or even JavaScript. All that your export button should do, IMO, is to create an AJAX request which triggers the process (query, transform results, publish to a correct content type, stream to browser) that will be needed to generate the content from your application server technology.
Sometimes you can't leverage an application server such as when your back end is a micro controller or you can't get the back end people to make the change.
I've not used this, but it looks nice:
http://www.sencha.com/forum/showthread.php?136598-Export-store-to-Excel

Implement drag-and-drop using AJAX in CakePHP

I wish to create a drag and drop feature for adding profile picture using CakePHP. Are there any samples which I can follow or a step by step guide?
I sourced many samples online but none of them cater for CakePHP.
I basically need a simple drag n drop for users to drag their profile image and the URL of the image is reflected in the database. The user will be able to edit another profile image. What approach should I use for this?
what you want to do is mostly about front-end, the back-end is generic server handling (in this case, PHP upload handling) and has little to do with Cake. That's why you don't see a specific cake tutorial for this. So, look up jquery drag drop and ajax upload. You'll also need to understand Cake rather well (well enough to adapt those online sample code to your Cake app).
I recommend you to use jQuery UI's draggable and droppable interactions.
Integrating them in CakePHP is quite easy, just follow the manual instructions to include Javascript files in a CakePHP application.
Finally, updating the database to reflect the URL of the image can be easily done with jQuery as well, using the AJAX related methods (e.g. post).

Drupal: storing images and other module data

Suppose we have a module that displays tables of employees. Each employee has a photo. What is the best way to store this photos and display them?
I mean, is there some kind of content repository in drupal? I don't want to do this manually, maybe there is an API that can store images and then generate links to them and so on.
Thanks.
The Content Construction Kit(CCK) / Fields in core is what you want to explore.
Using CCK you can attach an image, a number field, a file, some text, a reference to content, etc to another piece of content.
In Drupal 7 you can add fields to any entity (Content, User...your custom one(Employee)), in Drupal 6 you might want to explore Content Profile
Further Reading:
http://drupal.org/node/717120
There is a kind of content repository in Drupal: both in the database and as storage (disk).
The API for that is documented in a special File upload section.
If you want inspiration, the core module called upload.module can serve as example. But be aware that Drupal core, for several reasons, is far from the best and cleanest examples to learn from.
What you are looking for is CCK module with file-field and image-field modules for handling the image upload action.
And for the display of those uploaded images you should use Image-cache

Resources