Comments (10)
I made this easy solution:
`<div class="dropzone" ng2FileDrop [uploader]="uploader" (click)=fileInput.click()>
Drop or Click to select files
<input type="file" #fileInput ng2FileSelect [uploader]="uploader" multiple style="display: none;"/>
from ng2-file-upload.
To implement it right way you just need to replace "div" with "lable" and wrap file input field with it.
Something like:
<label ng2FileDrop [uploader]="uploader" class="my-drop-zone">
Drag and Drop File Here
<input type="file" ng2FileSelect [uploader]="uploader" style="display: none" />
</label>
No need to use "click" at all
from ng2-file-upload.
+1
from ng2-file-upload.
+1
from ng2-file-upload.
oh, nice one
from ng2-file-upload.
I solved this wrapping the file-select into the file-drop like this:
<div class="dropzone" ng2FileDrop [uploader]="uploader">
<div>Drop image here...</div>
<input type="file" ng2FileSelect [uploader]="uploader">
</div>
from ng2-file-upload.
try this https://github.com/valor-software/ng2-file-upload/tree/development/demo/components/file-upload/zs-file-demo
I think code is more clear then use drop & select at the same time.
from ng2-file-upload.
@fojt How to use this demo?
As your template include only <input>
tag with style="display: none;"
, so I guess it is intended to use with other tag or component. I tried to use your DemoFileUploadComponent using <demo-file-upload></demo-file-upload>
or <div DemoFileUploadComponent ...></div>
, but I got error TypeError: Cannot read property 'isSkipSelf' of null.
from ng2-file-upload.
I understand the error above occurs because, in short, FileUploader is not @Injectable(). So I remove providers: [FileUploader],
line and add @Input() public uploader:FileUploader;
so as to get existing FIleUploader instance, and check using <demo-file-upload [uploader]="uploader"></demo-file-upload>
from other sample-demo.html. Now I see how your component works.
Also it needs little fix for Firefox.
public onChange($event:any):void {
this.fileUploadService.addToQueue(($event.target || $event.srcElement).files);
}
from ng2-file-upload.
Added the following styles to div to make it cleaner:
.point{
cursor: pointer;
}
.my-drop-zone:hover {
border: dashed 3px green;
}
from ng2-file-upload.
Related Issues (20)
- Release Angular 15 compatible ng2-file-upload package (version 4.0.0 should get tagged as latest) HOT 6
- Angular v13 peerDependency support was removed
- Angular 16 Support HOT 4
- version 1.4.0 not compatible with Ivy engine HOT 1
- Make url optional
- Drag Folder With Files
- Dealing with UploadAll Function
- Existing Files - Add to upload queue as already completed
- .upload() uploads all files, not just one
- Inquiry About Code Contribution Procedure
- Angular V17 support HOT 12
- Directive not recognized even though Module is included HOT 1
- Blob.type is empty can still pass the Mime filter
- Could the file upload widget support pasting a buffered image from clipboard?
- ng2FileSelect not clickable HOT 1
- Angular 18 Support HOT 6
- Impossible to select file with the same name twice in select single mode HOT 1
- Support for Angular 18 HOT 2
- How to upload large files in parts
- release v7.0.1 is not the latest according to npm HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ng2-file-upload.