Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I am facing a weird problem , i am creating a module in ASP.NET & VB.NET which will allow user to upload Images using FileUpload Control.
Now it work perfectly in local but not in server.Also for all image on server
file1.PostedFile.ContentLength.ToString() give size =112 which is not correct.

Can any one help me on this?

What I have tried:

sImageName = file1.FileName
            sImageName = Path.GetFileName(file1.FileName)


            Dim postFile As HttpPostedFile = TryCast(Request.Files(0), HttpPostedFile)

            Dim intSize As Integer = postFile.ContentLength
            FileWrite("Log", "Start btnUpload_Click() intSize" & intSize.ToString())

            F
            If file1.HasFile Then

                FileWrite("Log", "Start btnUpload_Click() UploadedImage Start")

                FileWrite("Log", "Start btnUpload_Click() UploadedImage Start" & file1.PostedFile.ContentLength.ToString())

				 FileWrite("Log", "Start btnUpload_Click() ContentType" & file1.PostedFile.ContentType.ToString())
				 
                ' UploadedImage = System.Drawing.Image.FromStream(file1.PostedFile.InputStream)

                Dim file As HttpPostedFile = Request.Files("file1")

                FileWrite("Log", "Start btnUpload_Click() UploadedImage file" & file.ContentLength.ToString())


                If file IsNot Nothing AndAlso file.ContentLength > 0 Then
                    Dim fname As String = sImageName


                    sRootPath = objEasyPurl.GetConfigValue("RootTrackingSystemPath")

                    FileWrite("Log", "Start btnUpload_Click() sRootPath" & sRootPath.ToString())

                    sFileSavePath = sRootPath + "AG_" + iAgencyId.ToString() + "\" + "CompanyLogo" + "\" + sImageName

                    FileWrite("Log", "Start btnUpload_Click() sFileSavePath" & sFileSavePath.ToString())

                    sDirPath = sRootPath + "AG_" + iAgencyId.ToString() + "\" + "CompanyLogo"
                    FileWrite("Log", "Start btnUpload_Click() CompanyLogo" & sDirPath.ToString())
                    If IO.Directory.Exists(sDirPath) Then
                    Else
                        IO.Directory.CreateDirectory(sDirPath)
                    End If
                    file.SaveAs(sFileSavePath)
                    lblError.Text = "<script type='text/javascript'>CloseAndSetImage('" & sImageName & "')</" + "script>"

                End If
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900