Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL
The bolded line of code below works when ran locally....but will not work when published to the server and ran from the web.
The error it gives is: "can't find "c:/....."
I know what it's doing....it's trying to find that path/file on the server when it needs to be looking locally.
How do I make it look locally for that file/path so it can be converted to a stream?
I'm using the .ASP fileupload button that visual studio provides.
NOTE: the word filePath below is just a variable.....as I said above, I successfully load the file completely into my SQL Database when it's ran locally. I just can't make it look locally for a file when ran from the server.

 
FileStream fs = new FileStream(filePath,FileMode.Open, FileAccess.Read);
 
Thanks for any help/advice you can provide.
 
Jonathan
Posted 12-Jul-13 10:08am
Comments
joshrduncan2012 at 12-Jul-13 16:25pm
   
Is your goal for it to be able to be run from the server and look for a file that is stored on the server computer or stored on the client computer?
jhill444 at 12-Jul-13 16:42pm
   
run from the server......and look for a file that is stored on the client computer.
joshrduncan2012 at 12-Jul-13 16:47pm
   
C:\\.... probably won't work. It might be looking for a file stored on the server computer. I would recommend making "filepath" a UNC path to see if that works. (Not verified, just a suggestion).
jhill444 at 15-Jul-13 13:56pm
   
I've tried this several ways with no luck. Do you think I'm correct in thinking I'll need some sort of Java script to do this? what is the dang "upload file" button for if not this...maybe for use on a windows form? is it maybe not intended for server side execution?
Karthik J, Coimbatore at 13-Jul-13 0:52am
   
plz dont store any image to the database(My advice). Instead store the image in server(probably to ur project folder) and store only the image name in database.
Boipelo at 13-Jul-13 10:10am
   
Why not? scared of a huge database? Then have another database for images. Storing on folder is also a big risk - what happens when the folder gets deleted? All is lost.
jhill444 at 15-Jul-13 13:54pm
   
yeah, well, either way, my server admin won't let me put files on the server.
joshrduncan2012 at 15-Jul-13 13:59pm
   
I agree with Karthik. You have to factor in scalability when storing large files on database.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 295
1 OriginalGriff 274
2 Shweta N Mishra 216
3 PIEBALDconsult 184
4 CPallini 155
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 12 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100