adonespitogo / angular-base64-upload

Converts files from file input into base64 encoded models.
283 stars 121 forks source link

After selected a file input field shows "None selected" #103

Open juri33 opened 7 years ago

juri33 commented 7 years ago

How can i change the text in the input field? After selected a file the text is "None selected". Is this wanted behavior?

If i set breakpoint in my on-change function on angular.element("#input_imageUpload").innerHTML = this.uploadedImage.filename; i can see the filename in the input field but then it will be overwritten???

Is it also possible to change the input button text?

adonespitogo commented 7 years ago

This is the current behaviour, unfortunately. I'm not sure if this "wanted" though.

This happens because after selecting a file, we change the input value to empty in order that selecting the same file will trigger a change event. See the issue here #77

I did not realize it will change the text of the button to "None selected".

Yes, I think it is possible to override the button text. But this is currently not supported. Would you like contributing your solution and write a pull request?

juri33 commented 7 years ago

Thank you for your fast answer. Unfortunately we changed our requirement not to encode images :-|

venzeles commented 7 years ago

@juri33 adonespitogo/angular-base64-upload@c23ab67?diff=unified#diff-10e55e709b2fd51c2729a0fc806ec6bfR190 it's working

htalat commented 7 years ago

@adonespitogo, is it an intended behaviour to clear the filename (which normally appears when a file is selected)?

adonespitogo commented 7 years ago

No. This is a bug @htalat

htalat commented 7 years ago

@adonespitogo took a quick look at the code scope._clearInput is being called at the end of elem.on('change',fn) at line 307

can i make a pull request after properly testing it out?

adonespitogo commented 7 years ago

@htalat sure , much appreciated

htalat commented 7 years ago

@adonespitogo I don't understand why you have to clear the input after selecting a photo. If you are re-selecting the same one, the base64 string is already there in the model and hence no need to trigger the change event. The main feature of the directive is to get the base64 string which we already have, don't you agree?

Would you accept removing the scope._clearInput() call?

This is the current behaviour, unfortunately. I'm not sure if this "wanted" though.

This happens because after selecting a file, we change the input value to empty in order that selecting the same file will trigger a change event. See the issue here #77

I did not realize it will change the text of the button to "None selected".

adonespitogo commented 7 years ago

@htalat Please read the discussion here

I would accept removing scope._clearInput() call if you can provide alternative solution for the issue when selecting the same file

htalat commented 7 years ago

ah, it seems that the only way to trigger the change event is to clear the input. So i'll then make the change on my fork then since it fits my use case.

thanks for your time! :)

adonespitogo commented 7 years ago

108