Getting confused on image types. How to get filename?

Discussion in 'ASP .Net' started by Darrel, Jun 22, 2006.

  1. Darrel

    Darrel Guest

    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
     
    Darrel, Jun 22, 2006
    #1
    1. Advertising

  2. Darrel

    Darrel Guest

    > 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
     
    Darrel, Jun 22, 2006
    #2
    1. Advertising

  3. 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)




    "Darrel" <> wrote in message
    news:...
    >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
    >
     
    bruce barker \(sqlwork.com\), Jun 22, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    Extract filename from a filename typed by user

    =?Utf-8?B?Sm9l?=, Aug 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,060
    Travis Murray
    Aug 24, 2004
  2. Replies:
    1
    Views:
    1,572
    Roland de Ruiter
    Jun 15, 2006
  3. Ed
    Replies:
    10
    Views:
    46,530
    alok000707
    Jul 13, 2010
  4. Beauregard T. Shagnasty

    Re: filename.gif or filename.gif.jpg?

    Beauregard T. Shagnasty, May 30, 2008, in forum: HTML
    Replies:
    1
    Views:
    792
    Jonathan N. Little
    May 30, 2008
  5. Bergamot
    Replies:
    0
    Views:
    473
    Bergamot
    May 30, 2008
Loading...

Share This Page