Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hi folks,
I want to upload image when user selects image file from file chooser dialog box, rather than clicking the upload button.
as soon as user clicks on some file , it should immediately starts uploading the image that user has selected, rather than waiting for user to click upload button or submit the form.
can u please tell me how to accomplish this feature in imageField module.
I will really appreciate any help on this,
thanx in advance.
Satya
Comments
Comment #1
alippai CreditAttribution: alippai commented+1
Comment #2
alippai CreditAttribution: alippai commentedfeatures - IMHO to dev version
Comment #3
dopry CreditAttribution: dopry commenteda little jquery can be used to click the button when the input[@file] changes... I'll think about it in head...
Comment #4
jpetso CreditAttribution: jpetso commentednot critical.
Comment #5
quicksketchI implemented this for testing in HEAD version of FileField, but I found that it was a little jarring to have the upload immediately begin, especially with very large files.
You can easily add this to your own site though, adding this bit of JS.
You can just add this to filefield.js, but really I'd suggest putting it in your own theme or module JS files. Note this particular JS will only work on the latest dev versions.
Comment #6
quicksketchComment #7
SB CreditAttribution: SB commentedThis would be a nice option.
+1
Comment #8
edex13 CreditAttribution: edex13 commentedis there a way to make this code work for D5?
Comment #9
macrodesign CreditAttribution: macrodesign commentedsubscribe
Comment #10
quicksketchLet's move to FileField, since that's where this would be implemented.
Comment #11
Flying Drupalist CreditAttribution: Flying Drupalist commentedThanks, subscribe
Comment #12
Flying Drupalist CreditAttribution: Flying Drupalist commentedComment #13
frankcarey CreditAttribution: frankcarey commentedquicksketch, how about this a configurable option?
Comment #14
martin_qSeconding #13.
Presumably it is now appropriate to also request this as a feature for the managed-file form element in D7 core?
I agree that it is a matter of taste whether this is a good thing or not, but as soon as you have a big player like gmail doing it the other way (no upload button), your way starts to look counter-intuitive.
If the mod to the javascript is that short, then it can't be that hard to include this as a '#' option in the form API and thus leave the decision to the individual developers - and see if a consensus develops, or not... :)
Comment #15
quicksketchThis will not be added in FileField, which is essentially discontinued now that it has been merged into Drupal core. I'd suggest an add-on module, or like I said above in #5, adding this is as simple as a single line of jQuery.
Comment #16
igorik CreditAttribution: igorik commentedThanks quicksketch, your javascript works for me. I added hiding "Add" button too, because it has no sense to have it there if we upload image immediately on change of file upload form file.
This is my code in script.js in my theme
Comment #17
sbefort CreditAttribution: sbefort commentedThis works initially, but if the user selects the "remove" button after the file is uploaded, the upload button will reappear.
Comment #18
fxmasa CreditAttribution: fxmasa commentedThis:
$(this).parent().find('input.form-submit').mousedown();
doesnt work for me. I placed it to script.js in my theme (cleared cache of course), then also i tried to place it to filefield.js and nothing...
maybe beacuse i have jquery 1.3.2??
anybody knows?
Comment #19
fxmasa CreditAttribution: fxmasa commentedi have the latest version {dev} of filefield. i tried also the latest stable...
Comment #20
entrigan CreditAttribution: entrigan commentedThis code works for me until I have multiple file fields, at which point it duplicates the number of submits every new upload.
Comment #21
anglo CreditAttribution: anglo commentedWith multiple file fields submits are duplicated. Do you have the working javascript for multiple file fields?
Comment #22
tlaurent CreditAttribution: tlaurent commentedI'm not a Drupal expert and even less a jQuery one, but I think this modified version of igorik script should do the trick (should solve issue with remove/add file and multiple file fields):
Comment #23
Andrew Gorokhovets CreditAttribution: Andrew Gorokhovets commentedsubscribe
Comment #24
nevets CreditAttribution: nevets commentedThe uploadify module provides this functionality
Comment #25
Andrew Gorokhovets CreditAttribution: Andrew Gorokhovets commented#22 works for me
Comment #26
gregoiresan CreditAttribution: gregoiresan commented#22 works perfect
FYI : I am using jQuery_update module. To make the code working, I had to copy it in the FileField.js file.
Comment #27
gregoiresan CreditAttribution: gregoiresan commentedI guess the issue is closed then.
Comment #29
geoffv CreditAttribution: geoffv commentedCan someone assist me with implementing this change.
I need to make sure that the upload happens after browse.
Instructions here are saying, just put the code in your filefield.js
I have copied the code to the bottom of the filefiled.js file, and it has not made any change.
Comment #30
geoffv CreditAttribution: geoffv commentedall good, I figured it out.
Comment #31
cwithout CreditAttribution: cwithout commentedApologies for commenting an old issue. I just want to make it easy for anyone who's still looking for this functionality.
Check out the AutoUpload module. It handles auto upload on D6 FileField and D7 core managed file fields and one-click upload/select to the Media module's library.
Comment #32
rbasilious CreditAttribution: rbasilious as a volunteer commentedHello,
i want to do the exact opposite thing,
at a web from I want to upload image when user click on the submit file not after selecting the files.
can u please tell me how to accomplish this feature, i'm using drupal 8
Thanks