Custom File Filter Upload - drupal

I am developing custom upload module. I want to allow users to upload xls and xslx files only. How can I restrict this using file_save_upload function. Thank you

You should probably use the validate function for the form that has the file upload element on it instead. Or perhaps consider just using the File CCK element and using its settings to only allow files with xls and xlsx extensions to be uploaded - that would probably save you a whole lot of time.

Related

File extension validation in Symfony3

Is there any already implemented way to validate file extension in Symfony? File and Image validators can only validate mime type. Is there any way to do it or do I have to use a custom validator / callback?
You could use a RegexValidator if all you want to validate about is the file extension. Do keep in mind that a file extension in no way guarantees the contents of the file. Someone could upload an executable as a .png for instance.
Example
new RegexValidator('/(.+)(\.jpg|\.png|\.gif)$/')
Will match any filename ending in .jpg, .png or .gif
If you want more control over it (for example, passing an array of allowed extensions) I would recommend using a CallbackValidator or making your own. Good luck!

Meteor - Multi File Select UI to CollectionFS

I've been using yogiben/meteor-autoform-file, which is pretty awesome for uploading files directly to CollectionFS! However, uploading many files is a pain for the user: The user has to click the "+" icon once for each file to upload, and then select each file individually.
I could also use something like Blueimp JQuery File Upload for the multi-file select, but then the files don't get written to CollectionFS.
Is there an easy way to do multi-file select and have the files written to CollectionFS?
I used https://github.com/tomitrescak/meteor-uploads in a previous project. It supports collection-fs, has drag-n-drop and multiple files features. Maybe not as simple to put in place than yogiben's package but still. Take a look as it might fit your needs.

Style Drupal's Print Module PDF

How would one do this in Drupal 7? I want to add a few small style edits to the way the PDF outputs. I am using TCPDF. I read somewhere that its not posible with TCPDF, but other sources say it is. Should I be switching to dompdf? I've read the documentation but just can't seem to understand which file generates the PDF.
I have the module successfully generating a PDF from a View, so this is the last step in moving on with this project.
For anytime you want to style PDFs use DOMPDF, it will be less painful. Then style your pdf using print.css in the sites/domain.com/themes/yourtheme/css folder.
You can also copy the print.tpl.php file from the module's folder and paste it in sites/domain.com/themes/yourtheme/templates to choose exactly what you want to display in your pdf.

Uploading all files in a folder with Flex

I want to make a file uploader with Flex.
However, I want it to select a folder and upload all the files in the folder.
It would be much better if I can actually check the files before uploding.
I'm using Flex with JSP in the back-end.
Is there a way to do this?
So far, all I found from googling around is how to make file uploader for uploading a single file.
You can upload multiple files using the FileReferenceList class. There is an example at the bottom of the link.
When the FileReferenceList.browse() method is called and the user has selected one or more files from the dialog box that the browse() method opens, this property is populated with an array of FileReference objects, each of which represents the files the user selected. You can then use this array to upload each file with the FileReference.upload()method. You must upload one file at a time.

Is it possible to upload entire folders in ASP.NET?

The file upload control in asp.net does not allow me to select a folder and enables me to select only the files. Is there any way in which I can select a folder (obviously without using the file upload control).
Why I want to select the folder is basically to store its entire path in a database table.
The HTML <input type=file> element only supports single file uploads. If you to have multiple file upload, you would have to use a 3rd party component - usually written in Flash.
Here an example: http://www.codeproject.com/KB/aspnet/FlashUpload.aspx
No, browsing for files are the client-side feature, and the only information about file path is their name. It's cause security.
I dont think HTML supports what you are trying to do. Perhaps as a workaround you can have them select a file in the folder and then chop off the file name when processing it but thats a mess to be honest.
Ask them to Paste or type the path into a textbox perhaps. The issue here is you cant check for typos.
Id say you should rethink what you are trying to do.

Resources