Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with loading image file to a specific folder and path to an xml file

Hello,

How do you load an image file to the Application's image folder and copy it's path to an image file? Imager.xml. I am using vb.net programming language with ASP.NET.

<Image_ID>1</Image_ID>
<Image>Image/ImageA.jpg</Image>

Thanks,

Victor
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

I would imagine that you need get to get the inner text value from the <Image> tag, and use Server.MapPath to get the full name, and then process the image.
Avatar of Victor  Charles

ASKER

What control do I use from VS2010 to upload the image?. I have an image control on my form, once they upload the image, I would like them tio see in the image control. How do I achieve this?
Where is the file located?  
The users would be uploading the image from their PC to the application's AppData folder.
Would this name be relative to the AppData folder?

     <Image>Image/ImageA.jpg</Image>

That would be something like this:

Server.MapPath("~/AppData/" + fileName)

Open in new window

Yes, the files will be in the AppData folder, but the XML file will be in the following format:
<Image_ID>1</Image_ID>
<Image>ImageA.jpg</Image>

Once they load the image to the AppData folder, I will need to see it in the Image control in the form, or if possible load it in the Image Viewer before saving it to the AppData folder, which is probably a better approach incase the user doesn't like the way the image looks in the image control.

Thanks,

Victor
What are you asking for?  Are you asking how to use a FileUpload control?
Yes. and how to view the file in the ASP.NET image control once it's uploaded.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, I will try it and get back to you.
Hi,
I ran the project and tried to upload link.xml to a particular folder but I received the following error:
Could not find a part of the path 'c:\temp\uploads\Link.xml'.
on line:
FileUpload1.SaveAs(savePath)
How do I fix this error?
Thanks,
Victor

You need rights to write to that folder, since you are running in a partially trusted environment.

FileUpload.SaveAs Method
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.saveas.aspx

For a call to the SaveAs to work, the ASP.NET application must have write access to the directory on the server... You can explicitly grant write access to the account under which the application is running, in the directory in which the uploaded files will be saved.
I gave admin rights on my computer, will chek with my admin. One that is resolved, how do I automaticallt load the image file to an image control on the form?

Thanks,
Victor
If you have an image file, then you can set the Image.ImageUrl to the image file name.
Got it. Thanks