Fully Qualified Path Passed to Server?

P

pbd22

Hi.

Like the title says, I am trying to figure out a way to
pass the fully qualified path of each source file uploaded
to the server.

I am using an HttpPostedFile collection on the server and
hidden inputs with type=file (passed via iframe) to POST the
file collection.

Ideally, I would like each input to have value="c://path/to/file.gif"

I have done some reading on forums and I see a lot of "you can't do
that" as answers to similar questions. I you agree, I'd appreciate a
suggested solution. :)

I am building in ASP.NET 3.5 / C# and Flash or ASP's file upload
control are not options.

Thanks for your help.
 
E

Evertjan.

pbd22 wrote on 17 nov 2009 in comp.lang.javascript:
Like the title says, I am trying to figure out a way to
pass the fully qualified path of each source file uploaded
to the server.

I am using an HttpPostedFile collection on the server and
hidden inputs with type=file (passed via iframe) to POST the
file collection.

Ideally, I would like each input to have value="c://path/to/file.gif"

It is so easy to do, just ask the user to write it in an text input box.

[ But if you know already you want it always to be "c://path/to/file.gif",
why not hardcode that serverside? ;-) ]

The html file input box will not allow you to do that, as it is or should
be heavily defensive of any information about the local hd.
I have done some reading on forums and I see a lot of "you can't do
that" as answers to similar questions. I you agree, I'd appreciate a
suggested solution. :)

Leave it alone, seen from the server,
it is none of your business to know that.

Or do not use a browser, but write javascript as a cscript.
I am building in ASP.NET 3.5

Does not matter, this is not a serverside issue.
/ C# and Flash or ASP's file upload
control are not options.

Illogical, ASP.NET does not prevent you to use those.
 
T

Thomas 'PointedEars' Lahn

pbd22 said:
I am using an HttpPostedFile collection on the server and
hidden inputs with type=file (passed via iframe) to POST the
file collection.

Ideally, I would like each input to have value="c://path/to/file.gif"

I have done some reading on forums and I see a lot of "you can't do
that" as answers to similar questions. I you agree, I'd appreciate a
suggested solution. :)

You can't do that (as in "not possible for reasons of user security"), so
there is no solution. At least no user-friendly one.
I am building in ASP.NET 3.5 / C# and Flash or ASP's file upload
control are not options.

Why do you think the former excludes the latter two?


PointedEars
 
P

pbd22

OK, thanks for your replies.

Here is some more detail:

I am using a WCF method to upload a collection of image files. We
elected not to fuss with duplex channel uploads and, instead, are
using a helper class that attaches the upload stream to an event
handler and reports progress as the file is streamed from the client.

Below is the core of the code:

using (System.IO.FileStream stream = new System.IO.FileStream
(sourcePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)) {
using (StreamWithProgress
uploadStreamWithProgress = new StreamWithProgress(stream))
{
uploadStreamWithProgress.ProgressChanged += new
EventHandler<StreamWithProgress.ProgressChangedEventArgs>
(uploadStreamWithProgress_ProgressChanged);

FileTransferServiceClient client =
new FileTransferServiceClient();

client.UploadFile(fileinfo,
uploadStreamWithProgress);

client.Close();
}

}


void uploadStreamWithProgress_ProgressChanged(object sender,
StreamWithProgress.ProgressChangedEventArgs e)
{
int stub = default(int);

if (e.Length != 0)
stub = (int)(e.BytesRead * 100 / e.Length);

}


The "sourcePath" parameter has to be the path on the client to capture
the ProgressChanged event.

I cannot hard-code the file directory as I will not know where users
will select their pictures from. It is also a requirement that users
are "not" asked to input the file directory in a text box (seen as a
kludge). So, we need to be able to do this programatically.

Is there really no way of doing this?
 
P

pbd22

OK, thanks for your replies.

Here is some more detail:

I am using a WCF method to upload a collection of image files. We
elected not to fuss with duplex channel uploads and, instead, are
using a helper class that attaches the upload stream to an event
handler and reports progress as the file is streamed from the client.

Below is the core of the code:

using (System.IO.FileStream stream = new System.IO.FileStream
(sourcePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)) {
using (StreamWithProgress
uploadStreamWithProgress = new StreamWithProgress(stream))
{
uploadStreamWithProgress.ProgressChanged += new
EventHandler<StreamWithProgress.ProgressChangedEventArgs>
(uploadStreamWithProgress_ProgressChanged);

FileTransferServiceClient client =
new FileTransferServiceClient();

client.UploadFile(fileinfo,
uploadStreamWithProgress);

client.Close();
}

}


void uploadStreamWithProgress_ProgressChanged(object sender,
StreamWithProgress.ProgressChangedEventArgs e)
{
int stub = default(int);

if (e.Length != 0)
stub = (int)(e.BytesRead * 100 / e.Length);

}


The "sourcePath" parameter has to be the path on the client to capture
the ProgressChanged event.

I cannot hard-code the file directory as I will not know where users
will select their pictures from. It is also a requirement that users
are "not" asked to input the file directory in a text box (seen as a
kludge). So, we need to be able to do this programatically.

Is there really no way of doing this?
 
P

pbd22

OK, thanks for your replies.

Here is some more detail:

I am using a WCF method to upload a collection of image files. We
elected not to fuss with duplex channel uploads and, instead, are
using a helper class that attaches the upload stream to an event
handler and reports progress as the file is streamed from the client.

Below is the core of the code:

using (System.IO.FileStream stream = new System.IO.FileStream
(sourcePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)) {
using (StreamWithProgress
uploadStreamWithProgress = new StreamWithProgress(stream))
{
uploadStreamWithProgress.ProgressChanged += new
EventHandler<StreamWithProgress.ProgressChangedEventArgs>
(uploadStreamWithProgress_ProgressChanged);

FileTransferServiceClient client =
new FileTransferServiceClient();

client.UploadFile(fileinfo,
uploadStreamWithProgress);

client.Close();
}

}


void uploadStreamWithProgress_ProgressChanged(object sender,
StreamWithProgress.ProgressChangedEventArgs e)
{
int stub = default(int);

if (e.Length != 0)
stub = (int)(e.BytesRead * 100 / e.Length);

}


The "sourcePath" parameter has to be the path on the client to capture
the ProgressChanged event.

I cannot hard-code the file directory as I will not know where users
will select their pictures from. It is also a requirement that users
are "not" asked to input the file directory in a text box (seen as a
kludge). So, we need to be able to do this programatically.

Is there really no way of doing this?
 
P

pbd22

OK, thanks for your replies.

Here is some more detail:

I am using a WCF method to upload a collection of image files. We
elected not to fuss with duplex channel uploads and, instead, are
using a helper class that attaches the upload stream to an event
handler and reports progress as the file is streamed from the client.

Below is the core of the code:

using (System.IO.FileStream stream = new System.IO.FileStream
(sourcePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)) {
using (StreamWithProgress
uploadStreamWithProgress = new StreamWithProgress(stream))
{
uploadStreamWithProgress.ProgressChanged += new
EventHandler<StreamWithProgress.ProgressChangedEventArgs>
(uploadStreamWithProgress_ProgressChanged);

FileTransferServiceClient client =
new FileTransferServiceClient();

client.UploadFile(fileinfo,
uploadStreamWithProgress);

client.Close();
}

}


void uploadStreamWithProgress_ProgressChanged(object sender,
StreamWithProgress.ProgressChangedEventArgs e)
{
int stub = default(int);

if (e.Length != 0)
stub = (int)(e.BytesRead * 100 / e.Length);

}


The "sourcePath" parameter has to be the path on the client to capture
the ProgressChanged event.

I cannot hard-code the file directory as I will not know where users
will select their pictures from. It is also a requirement that users
are "not" asked to input the file directory in a text box (seen as a
kludge). So, we need to be able to do this programatically.

Is there really no way of doing this?
 
T

Thomas 'PointedEars' Lahn

pbd22 said:
I am using a WCF method to upload a collection of image files. We
elected not to fuss with duplex channel uploads and, instead, are
using a helper class that attaches the upload stream to an event
handler and reports progress as the file is streamed from the client.

Below is the core of the code:

Your C# code is not only likely not understood here, it is completely
irrelevant to your problem. Your C# code (or whatever) is server-side.
Your problem is client-side.
The "sourcePath" parameter has to be the path on the client to capture
the ProgressChanged event.

Tough luck.
I cannot hard-code the file directory as I will not know where users
will select their pictures from. It is also a requirement that users
are "not" asked to input the file directory in a text box (seen as a
kludge). So, we need to be able to do this programatically.

You can't. Find another way.
Is there really no way of doing this?

There is really no way of doing it *like this*. You cannot force the client
to provide information that it is supposed to hold back for security
reasons.


HTH

PointedEars
 

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,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top