CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.web_forms Tags:
Item Type: NewsGroup Date Entered: 2/12/2004 8:58:38 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 0 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
midoz
Asp.Net User
ContenType2/12/2004 8:58:38 AM

0/0

I want to check the content type of the file that the user will upload ,this code do the
lblMsg.text = "Error" is there something error in this code
If Not (myFile.PostedFile Is Nothing) Then
If myFile.PostedFile.ContentType <> "image / pjpegFile" Then
lblMsg.Text = "Error"
Else
Dim intFileNameLength As Integer
Dim strFileNamePath As String
Dim strFileNameOnly As String

'Logic to find the FileName (excluding the path)
strFileNamePath = myFile.PostedFile.FileName
intFileNameLength = InStr(1, StrReverse(strFileNamePath), "\")
strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath) - intFileNameLength) + 2)
Dim strPath As String = Request.PhysicalApplicationPath & "\upload\images\"
myFile.PostedFile.SaveAs(strPath & strFileNameOnly)
lblMsg.Text = "File Upload Success."
lblFileContentType.Text = "Content type: " & myFile.PostedFile.ContentType
lblFileSize.Text = "File size: " & CStr(myFile.PostedFile.ContentLength) & " bytes"

End If
End If
adhi_hn
Asp.Net User
Re: ContenType2/13/2004 12:28:57 AM

0/0

Hi,

This below code maybe can help you to solve your problem..
======================================

lblwarning.Text = ""
objFile = filUpload.PostedFile

If objFile.ContentLength = Nothing Then
Else
If LCase(Trim(Path.GetExtension(objFile.FileName))) = ".pdf" Or LCase(Trim(Path.GetExtension(objFile.FileName))) = ".doc" Then
con = New SqlConnection(Application("dataconnection"))
con.Open()
Try
strFileName = Path.GetFileName(objFile.FileName)
strFullName = Server.MapPath("documentreference") & "/" & Trim(strjobseekerid) & "/" & strFileName

If File.Exists(strFullName) Then
File.Delete(strFullName)
End If
objFile.SaveAs(strFullName)

strsql = "INSERT INTO tbdocumentseeker (jobseekerid,filename) VALUES ('" & strjobseekerid & "','" & strFileName & "') "
cmd = New SqlCommand(strsql, con)
cmd.ExecuteNonQuery()
Catch er As Exception
'Response.Write(er.ToString & "
")
End Try
con.Close()
Else
lblwarning.Text = "Please select a .pdf file."
End If
Call procBindDocumentList()
End If

Good Luck :)
Carpe Diem
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Intelligent Systems: Technology and Applications Authors: Cornelius T. Leondes, Pages: 2400, Published: 2002
Semantic Web and Education Authors: Vladan Devedzic, Pages: 353, Published: 2006
Mastering Microsoft Exchange Server 2003 Authors: Barry Gerber, Pages: 801, Published: 2003
Programming .NET Web Services: web services Authors: Alex Ferrara, Matthew MacDonald, Pages: 396, Published: 2002
Webmaster's Guide to the Wireless Internet Authors: Ryan Fife, Wei Meng Lee, Pages: 0, Published: 2001
The African State and the AIDS Crisis Authors: Amy Stephenson Patterson, Pages: 240, Published: 2005
Handbook on Quality and Standardisation in E-learning Authors: Ulf-Daniel Ehlers, Jan Martin Pawlowski, Pages: 573, Published: 2006
Visual Basic.NET and XML: Harness the Power of XML in VB.NET Applications Authors: Rod Stephens, Brian Hochgurtel, Pages: 503, Published: 2002
XML-komponenten in der Praxis Authors: unknown, Pages: 388, Published: 2003

Web:
response.contentype = applicaiton/pdf fails in IE - ASP.NET Forums response.contentype = applicaiton/pdf fails in IE. Last post 08-07-2007 9:44 AM by devsa. 9 replies. Sort Posts: ...
How to update Content and Contentype based on InstanceId - wMUsers How to update Content and Contentype based on InstanceId Trading Networks.
#1484887 (Wrong Conten-Type when sending Word or Excel attachments ... Wrong Conten-Type when sending Word or Excel attachments. Reported by: francesco_r, Owned by: till. Priority: 5, Milestone: 0.1.1 ...
[contributions:tolmi] /modules/icanlocalize/icl_content ... User: tolmi Branch: HEAD Date: Wed, 14 Jan 2009 11:13:40 +0000 Modified files: / modules/icanlocalize/icl_content icl_content.contentype.inc Log message: By ...
【转】HTTP协议中的ContenType类型大全- 胖胖熊- JavaEye技术网站 记录java 代码.* = application/octet-stream .001 = application/x-001 .301 = application/x-301 .323 = text/h323 .906 = application/x-906 .907 = drawing/907 .
Creating custom ContenType inheriting from Publishing Page contentType Creating custom ContenType inheriting from Publishing Page contentType.
DO NOT REPLY [Bug 30404] - default charset for conten-type header Subject, DO NOT REPLY [Bug 30404] - default charset for conten-type header. Date , Fri, 30 Jul 2004 19:36:33 GMT. DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST ...
[contributions:tolmi] /modules/icanlocalize/icl_content ... User: tolmi Branch: HEAD Date: Mon, 22 Dec 2008 13:36:53 +0000 Modified files: / modules/icanlocalize/icl_content icl_content.contentype.inc ...
[#GRAILS-2490] using response.contenType/Length generates 404 ... contenType/Length generates 404 responses for HEAD requests. Created: 20/Feb/08 08:31 AM Updated: 29/Jan/09 06:18 AM ...
[#VTK-890] Gjette contentype basert på filendelse i tilfeller der ... Gjette contentype basert på filendelse i tilfeller der det gjettes til application/octet-stream i utgangspunktet. Created: 16/Nov/07 02:25 PM Updated: ...




Search This Site:










question

required field validator causing problem?

is there a less-ugly way to do this?

how to change form action? thanks

dyanmically adding control and calling the function in it

disabling back button

asp.net 2.0 to 1.1 migration

create thumbnails !!!!

item style within a dropdownlist

icons in listbox

handling special characters

is there a "back" event in aspx file?

please help: listbox.selecteditem returns null

calling ms exchange mailbox from a website (intranet)

datareader and conditoinal statement

identifying what caused postback

texbox and decimal problem

how to log the exceptions in the text file from .aspx page

page_load running after a button click

remove extra spaces?

any ever had this problem

how to change webresponse

how do i insert an image in multiline textbox.

dataset filtering and datagrids

page refresh issues

date format in datagrid dd-mm-yyyy

inheritance

weird problem

can we transfer the session between two applications ?

pass in value upon mouseover

  Privacy | Contact Us
All Times Are GMT