Click to See Complete Forum and Search --> : ContentType problem with JPEG


Zelthor
12-19-2007, 07:08 AM
Hey guys,

I have a problem with uploading a JPEG-file to my webpage.
All the other file-types, like .txt, .doc, .xls and .pdf work but for some reason it keeps returning an error when I try to upload a .jpg-file.

This is the code I'm using:

' Check if any files were uploaded
If Uploader.Files.Count = 0 THEN
'doe niks
Else
' Loop through the uploaded files
For Each Files In Uploader.Files.Items
if Files.FileSize < 3000000 then
if Files.ContentType = "application/msword" then
Files.FileName = Request.QueryString("mnr")&".doc"
' Save the file
Files.SaveToDisk meldingsregistratieuploadpad
elseif Files.ContentType = "application/vnd.ms-excel" then
Files.FileName = Request.QueryString("mnr")&".xls"
Files.SaveToDisk meldingsregistratieuploadpad
elseif Files.ContentType = "text/plain" then
Files.FileName = Request.QueryString("mnr")&".txt"
Files.SaveToDisk meldingsregistratieuploadpad
elseif Files.ContentType = "application/pdf" then
Files.FileName = Request.QueryString("mnr")&".pdf"
Files.SaveToDisk meldingsregistratieuploadpad
elseif Files.ContentType = "image/jpeg" then
Files.FileName = Request.QueryString("mnr")&".jpg"
Files.SaveToDisk meldingsregistratieuploadpad
else
fout = "TRUE"
Response.write "alert('Alleen Word documenten toegestaan.');"
end if
else
fout = "TRUE"
Response.write "alert('Bestand mag maximum 3MB bevatten.');"
end if
Next
End if

if fout = "FALSE" then
Response.Redirect("bekijkuploadpage.asp?mnr="&Request.QueryString("mnr"))
else
Response.write "window.location='bekijkuploadpage.asp?mnr="&Request.QueryString("mnr")&"';"
end if

I also tried using gif instead of jpeg: that worked just fine.

Can anyone help me?

Thanx

vamsi616
01-04-2008, 05:47 AM
Hi Zelthor,

See the below part of code

elseif Files.ContentType = "image/jpeg" then
Files.FileName = Request.QueryString("mnr")&".jpg"
Files.SaveToDisk meldingsregistratieuploadpad

Replace that with

elseif Files.ContentType = "image/jpg" then
Files.FileName = Request.QueryString("mnr")&".jpg"
Files.SaveToDisk meldingsregistratieuploadpad

vamsi616
01-04-2008, 05:49 AM
Hi Zelthor,

See the below part of code

elseif Files.ContentType = "image/jpeg" then
Files.FileName = Request.QueryString("mnr")&".jpg"
Files.SaveToDisk meldingsregistratieuploadpad

Replace that with

elseif Files.ContentType = "image/jpeg" or Files.ContentType = "image/jpg" then
Files.FileName = Request.QueryString("mnr")&".jpg"
Files.SaveToDisk meldingsregistratieuploadpad

itHighway2007
01-12-2008, 12:36 AM
Try uploading 2 or 3 differnet .jpg files. Sometimes jpg file content type is not correctly written.