Getting confused on image types. How to get filename?

D

Darrel

I have a working function that grabs an image from a FILE form field and
get's the filename from it:

imageToCheck = myFormField.postedfile
checkedFileName = Mid(imageToCheck.FileName, InStrRev(imageToCheck.FileName,
"\") + 1)

I now want to grab the filename of an image that is already on the server:

sourceImage = System.Drawing.Image.FromFile("/my/file.jpg")

However, sourceImage.FileName is not valid. I've been googling, but am not
quite sure how to grab the filename. I'm also not exactly sure what type of
object a 'postedFile' is (knowing that would likely help me see the
difference).

-Darrel
 
D

Darrel

However, sourceImage.FileName is not valid. I've been googling, but am not
quite sure how to grab the filename. I'm also not exactly sure what type
of object a 'postedFile' is (knowing that would likely help me see the
difference).

Perhaps a better question...

Is there any sort of conversion/cast I can do on these two different image
types so I can pass them on to all the related functions as the same object
type?

-Darrel
 
B

bruce barker \(sqlwork.com\)

the inputfile has the posted file in memory. becuase it was part of the
request. the filename, is the filename the browser sent, not the servers
file name. if you want the image file saved on the server, you need to write
it out.

now a lesson on how to read the docs. in the docs you will see the
PostedFile (use the index) property is a HttpPostedFile. Click on
HttpPostedFile, it will take you the HttpPostedFile class. click on members
and you can see the properties and methods. there you will see stream object
to read the contents of the file, a handy SaveAs method to write the file to
disk.

-- gbruce (sqlwork.com)
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top