Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileUpload does not allow selecting same file #3385

Closed
veplechuc opened this issue Jul 13, 2017 · 2 comments
Closed

FileUpload does not allow selecting same file #3385

veplechuc opened this issue Jul 13, 2017 · 2 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@veplechuc
Copy link

I'm submitting a ...

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior

I have defined the component this way
<p-fileUpload #fileUpload accept=".csv,.txt" maxFileSize="1000000" customUpload="true" (uploadHandler)="uploadFile($event)">

on my package Json I have defined

"primeng": "^4.1.0-rc.3"

and have this method on the js file

uploadFile(event) { for (let file of event.files) { this.uploadedFiles.push(file); } this.uploadFileService.doSomething(this.uploadedFiles[0]).subscribe(x => { this.fileInfo = x; ..do some stuff.. }); }

It works as expected the first time (showing the 3 buttons of the component choose, upload and cancel) and letting me to choose the file from the popup window, the thing is, one it finish the process, if I try to upload the same file again It does not allows me to do it. It only allows me to choose the file, but the upload button is never enabled (unless I choose a different file, in that case the upload button is enabled) and of course the uploadfile method is never called. And after that if I choose the same file as the begining it works as expected.

I am using

this.fileUpload.clear();

just for clear the part where the uploaded file it is showed to the user

Thanks

Expected behavior
I think I should allows me to upload the same file.

Minimal reproduction of the problem with instructions
The example showed on http://primefaces.org/primeng/#/fileupload has the same behavior

Please tell us about your environment:
Windows 10, Visual Studio Code

  • Angular version: 4.0

  • PrimeNG version: 4.1.0-rc3

  • Browser: [Chrome XX]

  • Language: [ ES6/7 | ES5]

@kheckelmann
Copy link

I had problems with this issue today too. The problem seems to be, that the input of type file is never cleared, so after uploading the file the input still contains it and because of that onFileSelect is not called when selecting it again. Maybe it would be enough to just clear that input in the clear method?

It seems to work in the 'basic' mode because there the input contains a ngIf so that it is only there if no files are selected. Because of that the input is always "fresh" when the dialog is opened and the onFileSelect gets called correctly. There is no such thing in the advanced mode.

I really would appreciate a quick fix.

@dremlin
Copy link

dremlin commented Jul 17, 2017

I have got the same issue in Angular 4.3 and PrimeNG 4.1.0.

  1. The component does not react on "multiple" input parameter. If I set up multiple="multiple" or [multiple]="true" the component does not allow me to choose multiple files when I click on "Choose" button. However, I can drag and drop a file and it will be displayed in the attached file list below.

After n investigation I found out that the following CSS class hides the input Html element

.ui-fileupload-choose.ui-fileupload-choose-selected input[type=file] { display: none; }
As a temporary solution I just override the CSS class as

.ui-fileupload-choose.ui-fileupload-choose-selected input[type=file] { display: inline; }

  1. If I choose a file and add it to the list and remove the file (so the list is empty), I cannot choose the same file again. It looks like the file's metadata saved somewhere. However, public files: File[] array is empty.

@cagataycivici cagataycivici changed the title p-fileUpload does not work more than once FileUpload does not allow selecting same file Aug 10, 2017
@cagataycivici cagataycivici self-assigned this Aug 10, 2017
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Aug 10, 2017
@cagataycivici cagataycivici added this to the 4.1.3 milestone Aug 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

4 participants