Question
· Jan 15, 2018

How to get (Win) drive letter and directory in upload.csp Sample?

New to Cache and CSP,

Hacking up Sample upload.csp and was wondering if you can get the drive letter and director (on a Windows system) on the file that is picked?

I cannot find anything on MIMEDATA, such as FileName, Size, MemSection, etc that can do this.

Another meothod that can accomplish this?

Discussion (5)0
Log in or sign up to continue

Dmitry,

Thanks for the response and I totally understand this answer.

So then, based on the Samples upload.csp, once the file is picked, how would you write this to a Cache database?

I've already written a Cache class that will read in a file and create a database.  I used %Stream.FileCharacter to accomplish this.

I'm not clear how I can do this within a csp and what is provded in the upload sample.

In HTML world, we have two sides. Server and Browser. Upload means that some users far from our server can choose the file on their machines and upload it to the server through the network. The server will get full this file and only filename. You can't get file path because it is useless to you. If you would run this file in a browser and try to choose any your local file then push upload file button. You will get some information about this file, like for me.

the code is already included in the CSP example
the file comes a MIME data in %request:

for easier reading compile the CSP file and see the generated class   csp.upload.cls  in SAMPLES


<!-- As form is submitted to this page look to see if we have the stream in the %request object -->
<csp:if condition='($data(%request.MimeData("FileStream",1)))'>
<hr><br>
Submitted filename: <b>#(..EscapeHTML(%request.MimeData("FileStream",1).FileName))#</b><br>
Size of file: <b>#(..EscapeHTML(%request.MimeData("FileStream",1).Size))#</b><br>
Mime Section: <b>#(..EscapeHTML(%request.MimeData("FileStream",1).MimeSection))#</b><br>
Type of stream: <b>#(..EscapeHTML($classname(%request.MimeData("FileStream",1))))#</b><br>
Content Type: <b>#(..EscapeHTML(%request.MimeData("FileStream",1).ContentType))#</b><br>
<br>
First 200 characters of stream:<br>
<ul>
<script language="Cache" runat="server">
 

See also doc on %CSP.Request

http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?P...

You may try to cheat it by changing the <input> tag to 

    <input type=file size=30 name=FileStream onchange="javascript: alert(this.value);">

and you get in CHROME  and Firefox

C:\fakepath\EUR_Meldung.pdf

and fakepath doesn't exist obviously

while IE11 and EDGE on Windows10 tell me the real path (!)

C:\Users\ich\Desktop\EUR\EUR_Meldung.pdf

I give no further comment related to security & privacy on products from M$