Get file path from the client

S

Sathyaish

I am not a Java programmer and I have a question about a web
programming scenario in Java. Can you please tell me if it is possible
for the server to retrieve the file name and path of a file selected by
a user on the client machine using the Save file dialog control built
into Windows?

Here's the scenario.There's a button called OK. When it is clicked, a
Save file dialog (the windows common dialog that lets you select a file
to open or save) pops up on the client. The user chooses a file name
and location to save a new file. In the click of the same button,
records from a database are then transferred to the client machine in
that location with that file name.

In ASP.NET I know it would be possible because the OK button's click
event handler would execute on the server because it'd be a server
control. And so it'd look something like this in ASP.NET:

public void btnOK_Click(object sender, EventArgs e)
{
//psuedocode
string sPath = FileDialog.Show();

//sPath is the location and name of the file on the client's hard
drive
}


Is it possible in Java?
 
S

Sathyaish

public void btnOK_Click(object sender, EventArgs e)
{
//psuedocode
string sPath = FileDialog.Show();

//sPath is the location and name of the file on the client's hard
drive
}


Just to pick a nit, I wrote the wrong psuedocode for ASP.NET, I
realize. The filedialog returns a DialogResult and not a filename. The
file name can be known from the filedialog's FileName property, so it'd
look more like:

public void btnOK_Click(object sender, EventArgs e)
{
//psuedocode
FileDialog.Show();
string sPath = FileDialog.FileName();

//sPath is the location and name of the file on the client's hard
drive
}

or something like that. So, it is possible in ASP.NET. Is it possible
in Java/JSP/whatever?
 
O

Oliver Wong

Sathyaish said:
Just to pick a nit, I wrote the wrong psuedocode for ASP.NET, I
realize. The filedialog returns a DialogResult and not a filename. The
file name can be known from the filedialog's FileName property, so it'd
look more like:

public void btnOK_Click(object sender, EventArgs e)
{
//psuedocode
FileDialog.Show();
string sPath = FileDialog.FileName();

//sPath is the location and name of the file on the client's hard
drive
}

or something like that. So, it is possible in ASP.NET. Is it possible
in Java/JSP/whatever?

I am shocked that this is possible via ASP.NET. Can you post a link to
an ASP.NET page which just gives me a file save dialog, and then I'll try
saving it somewhere, and then your page tells me the filename of the file I
saved it to? I can't bring myself to believe that ASP.NET would provide such
a privacy breach. I'm expecting for the code on the serverside to throw some
sort of security exception or something like that. I really have to see this
for myself.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top