HTML5: What should server do when user uploads folder? - html

HTML5 does not allow directory upload.
But inevitably, some users will end up uploading a folder, because they don't know about HTML5 rules.
The uploaded folder is just a small file.
How should I handle those cases?
Should I pretend the user really wanted to upload this small (probably meaningless) file?
Should I try to check if uploaded file is actually a folder, and warn the user if it is? (the actual data of a folder file is different on every OS, so not that easy)
Is it the browser's fault, should Chrome prevent the user from HTML5-uploading a folder?
Note: Alfresco uses the first strategy. If you know any application that uses the second strategy I would be glad to hear about it.

Alfresco has recently changed their strategy to the second strategy.
If the uploaded item is a folder or has a null size, it is refused server-side, and the Web UI tells the user.
I guess it is the best thing to do for now.

Related

Is it possible to access and list files of local system in web browser.

My requirement is to show a panel where I list the local system directory, from where I drag and drop the files inorder to perform operations on it.
In HTML5 the FileSystem API is available , but most of the browsers are not supporting.
Is it possible by using input type as file? Like we browse and select a directory, then we can see the list of files and their details?
As the previous commenters correctly noted, this is not possible because it is considered a security hole. Think about a malicious script that could read out everything on your local file system just by visiting a web page.
You can however implement file drag-and-drop like this: https://github.com/moxiecode/plupload

Can chrome extension modify a file in our hard drive?

I am making a chrome extension which needs to add/delete/modify file in any location in our hard drive. The location can be temporary folder. How is it possible to make it. Please give comments and helpful links which can lead to me have this work done.
You can not, but adding a local server (nodejs/deno/cs-script/go/python/lua/..) to have a fixed logic (security) to do file stuff and providing a http server to answer back in an ajax/jsonp request would work.
The extension will not be able to install the software part.
edit: if you want to get started using nodejs, this could help
edit2: With File and Directory Entries API (this could help) you can get hold of a FILE OR complete FOLDER (getDirectory(), showDirectoryPicker()).
Thankfully, this is impossible.
Google or any other company wouldn't have many friend if their extension(s') installation caused compromise including complete control over any files(ie. control over machine) on your hard drive. The extension can save information to disk in a location that is available for storing local information as mentioned. You will not have any execute permission on the root or anywhere nor will you have any read or write permission outside of the storage location.
However, extensions can still be malicious if they gather information from a user of a web page (I am sure that Google can filter some suspicious extensions).
If you really need to make changes on your hard drive you can store information on a server and poll for changes with a windows client application or perhaps you can find where the storage information is kept and access it from there from a windows app.

Is it possible to open a users local file for read using HTML5?

I have a path to a file on the users local system. When the user clicks on that path, the file should open so that the user can view it.
I know that there are lots of limitations on this since we cannot access a users local file due to browser security issues.
Now, I read about HTML5 and it's FileReader API, but all the code examples I see online select and upload the file, and I'm not very clear about whether it is possible to do what i want with it.
Maybe I haven't looked at the right places yet, but anybody know about this?

How to Browse Server files using Flex4

I need to show the server uploaded files in flex 4.5 for a web application to manage the uploaded files like upload, delete and open for preview.
Can anyone help me How to list the sever side files in Flex action script3.0?
You can't just let Flash player browse your server files. But you could create a workaround.
Make a script on the server which will give you the list of files located at the path you're looking for. Through basic POST you can ask for a list of files for a directory. Then you can display it in your flash side. But remember every actual action that happens to your files MUST happen on the serverside. Also BEWARE such things, because it's really easy to look up network requests that are made in browser, so you may end up with all of your files deleted one day. So make sure you implement some security stuff.

Is it possible to open an excel file in its current location not download it

I am writing a small web site for a company Intranet and have the following question that may be simple. Is it possible to open an Excel file from it's current location on the network instead of downloading it. So that any changes made are made to the actual file and not a downloaded version of it?
Thanks
Matt
Yes, it's possible, but then you would have to specify the address of the file in the local network, not as an HTTP address on the web server.
The user would naturally need to have access to the file on the network share, with write permission.
No. It is not possible to open a remote excel file across HTTP and write changes back to it.
Let's consider some other things you might be trying to do.
If you are running excel, all you can open are files visible to the file system APIs. That means files on your local disk and network file systems accessible via CIFS. Mapped drive letters, \\ pathnames, that sort of thing.
If you set up an Excel file for download from a web server, it will always be downloaded. Excel won't open it 'in place'.
The Microsoft technology solution that addresses what you seem to be asking for is Sharepoint.
Anything you open from a HTTP connection I believe is "downloaded" to the client. Its more how you "uploade" the changes.
But if thats what the customer wants I have some alternatives:
1) Use Dropbox or similar filesharing utils. Once someone saves a document in Dropbox, its automatically uploaded to the Dropbox account. The free version allows up to 2 GB of data. Thats quite a few Excel files.
2) Use Gmail/Google Apps. If you do you get 1 GB space for online documents. You can upload Office files suchs as Excel and they will be converted an online editable from within the Google Docs. You can share the files within the domain or even externally if you make that setting the admin part. Afterwards you can also download/export the Spreadsheet as Excel format. I havent tested how much of the standards you loose but ofcause its not a full Excel.
3) wait for Microsoft to finish their Office online. I bet that Excel version will do exactly what you are currently asking for by using some special plugin or MSIE9 technics. But I dont really know yet.
Hope some of this gave you some ideas?
If the file is in a network share on the same domain (or reachable from the domain your app is running from), it is possible, provided that
The share is readable and writeable by the domain\user the app runs under (via ownership or assigned role.)
The file is shareable (IIRC). This is important if multiple users (or apps) need to access it.
Other than that, a \domain\location path should be treatable just like a local (or disk mounted) path.
In your HTML document, create/place a link:
<a href='file:///H:/docs/foo/bar.xls'>Your Excel File</a>
Substitite your network UNC path for H:/docs/foo/bar.xls. Note the slashes instead of the regular UNC backslashes.