In my ASP 3.5 page, using VB code, I want to upload a picture from my local drive and save it on the server. This VB code: ------------------------------------------------------------ Dim MyFileCollection As HttpFileCollection = Request.Files ' Create a new file name. TempFileName = "~\ALFSDev\Assets\X" ------------------------------------------------------------ An error msg is generated when I run the page: "The SaveAs method is configured to require a rooted path, and the path '~\ALFSDev\Assets\X' is not rooted." Any idea how I should express the path and filename on the server?
Try the absolute path. You can find that in the Control Panel Account Information section. The format will be something like: e:\web\YOURACCOUNTUSERNAME\htdocs\ALFSDev\Assets\X
I got "e:\web\dbireporter\htdocs\" from my Account Information. However, when I tried "e:\web\dbireporter\htdocs\ALFSDev\Pictures\xxx.jpg" I got the following error msg: "Could not find a part of the path 'e:\web\dbireporter\htdocs\ALFSDev\Pictures\XXX.jpg'." Any idea what I'm doing wrong?
By the way, I'm doing this to save the file: Dim MyFileCollection As HttpFileCollection = Request.Files MyFileCollection(0).SaveAs(filePath + fileName) Where filePath + fileName = "e:\web\dbireporter\htdocs\xxx.jpg"
My code saves to my local machine, but not to the server. I do have a drive E: on my local machine. Do I need to somehow specify that I want to save to the server?
The solution was so obvious, I am ambarrassed I posted this. Please remove this thread. Running on my local machine, of course it saves to the local drive. Running on the server it works just fine! Duhhh!
Hey, no worries. We've all done it, and that's not even close to the most embarrassing oversight I've seen. I'll remove the thread if you'd like, but it would be good to leave it for someone else to benefit from if you don't mind.