Show file path in firefox/chrome [duplicate] - javascript

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Full path from file input using jQuery
I have the following html element
<input type="file" id="upload">
If I use
$("#upload").val();
I only the file name, not the complete absolute path of the file. Can someone tell me how do get the complete path?

You cannot do so - the browser will not allow this because of security concerns. Although there are workarounds, the fact is that you shouldn't count on this working. The following Stack Overflow questions are relevant here:
full path from file input using jquery
How to get the file path from HTML input form in Firefox 3
In addition to these, the new HTML5 specification states that browsers will need to feed a Windows compatible fakepath into the input type="file" field, ostensibly for backward compatibility reasons.
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-March/018981.html
The Mystery of c:\fakepath Unveiled
So trying to obtain the path is worse then useless in newer browsers - you'll actually get a fake one instead.

Related

Generate csv file from javascript with special characters [duplicate]

This question already has answers here:
How to open a text file with Excel in UTF-8 encoding?
(1 answer)
Replace values across ALL worksheets with new value
(2 answers)
Closed 4 years ago.
This the follow of this topic Here.
Now I can generate and open a csv file. I just have a small problem with special characteres like €...
When I open file with notepad++ : no problem. But under excel I've funny charactere...
Same problem with file generate with IE, Chrome or FF.
In notepad++, say encoding UTF-8. I think Excel try other encoding. Is it possible to force work with utf-8 for csv file or do i change encoding in my codes... I've no idea about good way to take.
UPDATE
I see methods to force Excel to open it in good format, but I need a methods more simple. It's an extract. When you click on button you don't want save on desk, Open Excel->Data... 10 clicks after see the good result.
I search a method more automatic, you click, you see. Hoping is it possible???
UPDATE 2
And solution, but my question is wrongly put to duplicate.
In fact, the solution is to add in javascript generator code a string to force Excel to open in UTF-8 directly. With this one and this other one
I correct my code fir IE>9 and Chrome and FF (other i don't care know)
if(window.navigator.msSaveBlob){
var blob = new Blob([new Uint8Array([0xEF,0xBB,0xBF]),result],{type:'application/csv;charset=UTF-8'});
window.navigator.msSaveBlob(blob,filename);
}else if(window.webkitURL != null){
var a=document.createElement("a");
a.href="data:application/csv;charset=UTF-8,%EF%BB%BF" + encodeURIComponent(result);
a.download=filename;
a.click();
}
Just enjot it :-)

How to assign the variable value to the input type "file" [duplicate]

This question already has answers here:
Dynamically set value of a file input [duplicate]
(4 answers)
Closed 8 years ago.
Hi I have small requirement, is there any way to update variable value to the input type file value (Browse).
<input type="hidden" value="Testfile - CSV - 100 rows.csv" id="filePathHdnID" name="filePathHdn" />
<input class="fileType" name="uploadfile" type="file" id="idUploadFile"/>
Here is jquery code what I tried
$("#idUploadFile").val($("#filePathHdnID").val());
Please share me your ideas, sorry if it is confused.
Looking at your requirement, you want to set a default file path for the file input control.
Unfortunately, this is a very common requirement that every client wants, but not possible using javascript because of Security Reasons.
What if possible: You as a developer can modify the file input and post it to server, and the actual user will not get notified. Any
feature/requirement of language that creates a security threat is kept closed
for developers :)
You cannot change the value of file input.
Because file object created once you has a file selected, and
File object that contain useful information about the file.
name
The file's name as a read-only string. This is just the file name, and does not include any path information.
here the file name is the value you want to change.
doc

How to avoid displaying "C:fakepath" in browsers [duplicate]

This question already has answers here:
How to resolve the C:\fakepath?
(13 answers)
Closed 9 years ago.
How to avoid displaying "C:fakepath" while file uploading. While uploading the file javacript method is called to set the selected path im my case
This is a browser security feature that is implemented.
According to the specifications of HTML5, a file upload control should not reveal the real local path to the file you have selected, if you manipulate its value string with JavaScript. Instead, the string that is returned by the script, which handles the file information is c:\fakepath.
If you still want to get rid of this fakepath you may check out this site
How To Get Rid of C:\FakePath in IE When Uploading A File to the Website
Hope it helps.

how to encrypt html page source code using javascript functions [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to encrypt HTML, CSS and JavaScript to prevent theft
Please tell how to encrypt html page surce code for any webpage using javascript function if not possible then please tell alternative ways..
In order for the source to be rendered, it has to be decrypted in the browser and a DOM constructed, which which point the user can use a DOM inspector to access the DOM and serialize it back to HTML (thus creating a reasonable facsimile of the original HTML).
Thus there is no way, alternative or otherwise.

Is it possible to remove the 'cache' from the request headers with js? [duplicate]

This question already has answers here:
How do we control web page caching, across all browsers?
(29 answers)
PDF freezing browser - do I have enough information to isolate the cause?
Closed 8 years ago.
Basically, I need to remove the 'cache' part of request headers when requesting a particular static resource (a pdf).
Is this possible to achieve?
A bit more context:
I'm comparing two calls to a file (calls as in assigning the path of pdf to a src attribute of an iframe). One works, one doesn't. Using fiddler2 I've had a look at the traffic and it appears that the only difference is that the request headers of the request that doesn't work includes If-Modified-Since in the 'cache' part of it's headers. If I can remove this I think it'll solve the issues I'm having as I understand caching and iframes displaying pdfs can be potentially problematic. If I'm wrong, and it doesn't solve it, I'll at least have ruled that out as a problem.
EDIT: This is a problem exclusive to IE 8 if that's any help: https://stackoverflow.com/questions/13528332/pdf-freezing-browser-do-i-have-enough-information-to-isolate-the-cause
Like #Lee Taylor said, use a unique variable in your path. Mostly this is done with a timestamp since it's unique.

Categories

Resources