-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: TechSavyKrithik
Message 2 in Discussion

Hi tpb,

I have similar code working fine with me. I am also attaching the code snippet. Try 
with this code

----------------------------------------------
'The first argument is the file chooser control, second is the file name to save, and 
third one is the destination path 

    Private Sub UploadImage(ByRef filechoose As 
System.Web.UI.HtmlControls.HtmlInputFile, ByVal strfilename As String, ByVal strpath 
As String)
        Dim strFNWithPath As String, strContType As String, strContLen As String
        'Dim strFileName As String
        Dim strServPath As String, strImgType As String, intPos As Integer
        Dim strNewFileName As String = strfilename '"complogo.gif"
        Try
            strServPath = Server.MapPath(strpath)
            strServPath = strServPath & "\"

            strFNWithPath = filechoose.PostedFile.FileName
            strContType = filechoose.PostedFile.ContentType
            strContLen = filechoose.PostedFile.ContentLength
            strfilename = System.IO.Path.GetFileName(strFNWithPath)

            If strfilename = "" Then Exit Sub
            intPos = InStrRev(strfilename, ".")
            strImgType = Mid(strfilename, intPos + 1)
            strImgType = LCase(strImgType)
            Dim objImage As System.Drawing.Image, objStream As Stream
            Dim objFile As System.Web.HttpPostedFile

            objFile = filechoose.PostedFile
            Dim strErrType As String
            objStream = objFile.InputStream
            strErrType = ""

            If strErrType = "" Then
                Dim strTempNewFileName As String
                Dim strNewAssignedFileName As String
                Dim Ctr As Integer = 1
                strTempNewFileName = strServPath & strNewFileName '& "." & strImgType
                'While File.Exists(strTempNewFileName) = True
                'strNewAssignedFileName = strNewFileName & "_" & Ctr
                'strTempNewFileName = strServPath & strNewAssignedFileName & "." & 
strImgType
                'End While
                Try
                    'Response.Write("The file name is  " & 
filechoose.PostedFile.FileName)
                    filechoose.PostedFile.SaveAs(strTempNewFileName)
                    Dim strImageName As String
                    strImageName = strTempNewFileName
                Catch ex As Exception
                    strErrType = ex.Message
                End Try
            End If
        Catch ex As Exception
            'lblMsg.Text = "Technical error occured. For more information view log 
file"
            WriteToLog("Capturecompanydetails.aspx.vb::Page_Load" & ex.Message & "::" 
& Now(), Server.MapPath("../bin"))
        End Try
    End Sub


---------------------

If you have any other problem contact me.

With regards,

Krithika

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to