473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Response.ContentType problems

I got this in my code : Response.ContentType = "image/jpg" or image/jpeg or gif or bmp

I cant open this asp page with internet explorer.

I get a message error: Internet explorer cannot download test1.asp from localhost or when i cut &paste the code(from that file) in a new document in frontpage internet explorer want to download the file or open it with frontpage.

I just wanna know why yesterday I work with the same exact page and I dont get this error message and download things. And what's the matter with Response.ContentType ?

And when it work the only thing I got is tons of ascii characters like this : $ÿÿÿÿPackagePackage... why ?
Oct 27 '06 #1
6 9367
Frinavale
9,735 Expert Mod 8TB
By default the Response.ContentType is set to text/html which will allow for the content to be written to and understood by the browser.

If you change the content type, browsers can no longer understand what has been sent to them since they cannot interpert anything except text/html.

If you change content type then the content needs be opened with an application that understands that content type.

I'm not sure if this helps you at all as I'm not quite clear on what you are trying to do.
Oct 27 '06 #2
By default the Response.ContentType is set to text/html which will allow for the content to be written to and understood by the browser.

If you change the content type, browsers can no longer understand what has been sent to them since they cannot interpert anything except text/html.

If you change content type then the content needs be opened with an application that understands that content type.

I'm not sure if this helps you at all as I'm not quite clear on what you are trying to do.
Hi :)

Here is the code :

<%
set conn=server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.jet.OLEDB.4.0"
conn.Open "F:/projet/test1.mdb"

set rs= conn.Execute("SELECT photo FROM photos where ID=1")

Response.ContentType="image/jpg"
Response.BinaryWrite(rs("photo"))

conn.Close
%>

Normally i would expect to see a image from the database
But the only thing I got is tons of ascii characters like this : $ÿÿÿÿPackagePackage

Another problem
And now after some refresh (code hasnt change) Internet Explorer give me a messagebox with prompts as follows:
==================================
Title: File Download - Security Warning
Name: Setup.exe
From: localhost

Buttons: [Run] [Save] [Cancel]

While files from internet can be useful, this file type can potentially harm your computer. If you do not trust the source, do not run or save this software. (link: ) What's the risk?
================================

i copy paste the code in a new asp file
it works like 3 or 4 times (doing some refresh) and then the messagebox come back.

I try other browser like Firefox and Opera and its the same thing
I tried to change security level for intranet too, but i don't know which parameter to change.

thanx for your help
Chris
Oct 28 '06 #3
r_o
35
hey man
i don understand why you wanna set the content type to image/jpeg because by default IE and most browsers can read it easily
so you just insert the image into the web page and the browser will display it for ya
Oct 28 '06 #4
hey man
i don understand why you wanna set the content type to image/jpeg because by default IE and most browsers can read it easily
so you just insert the image into the web page and the browser will display it for ya
Ok so give me the code that take a image from a database and display it.

<%
set conn=server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.jet.OLEDB.4.0"
conn.Open "F:/projet/test1.mdb"

set rs= conn.Execute("SELECT photo FROM photos where ID=1")

Response.ContentType="image/jpg"
Response.BinaryWrite(rs("photo"))

conn.Close
%>

thanx
Chris
Oct 28 '06 #5
r_o
35
Response.ContentType="image/jpg"
Response.BinaryWrite(rs("photo"))
i think response.binarywrite(rs("photo")) should do it itself
Oct 30 '06 #6
i think response.binarywrite(rs("photo")) should do it itself
The code :

<%
set conn=server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.jet.oledb.4.0"
conn.Open(server.MapPath("test1.mdb"))
set rs= conn.Execute("SELECT photo FROM photos where ID=1")
%>

<img src="<%Response.BinaryWrite(rs("photo"))%>">

<% conn.Close %>

I think you 're right on this but the only thing I get is ascii code like this : ÿÐÿõ«®C¸Yö>w[–¸Œç1sÐåA....

Don't know why :( Can you help me on that

Thanx for the help
Chris
Oct 30 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jawahar Rajan | last post by:
All, I have an ASP Application in which users can save a recordset as an Excel spreadsheet should they choose to do so. When the app was on test box all was well but when I moved it to...
5
by: Joan | last post by:
I am creating a word document from an asp page. I have no problems actaully creating the document and creating some tables that have data in them. I am using Response.ContentType =...
1
by: Charlie | last post by:
Hi: I'm uploading documents into a SQL Server Image field and using Response.BinaryWrite() to download or view them in the browser. Some doc types like Adobe Illustrator and Photoshop files...
4
by: david | last post by:
I has a question: I can use Response.WriteFile to display images such as .jpg. But I can not us it to display words doc file in EI by calling Response.WriteFile("testdoc/DownloadLarge.doc"). It...
6
by: john | last post by:
The standard method to transmit a file from an aspx page to a browser is to stream the file to the response then end the response. The HTML code generated by the aspx page is discarded, and the...
8
by: Katie | last post by:
Hi, I am trying to set the content type and header for the response object but for some reason it doesnt set it. I tried it on dev and it worked fine but didnot on production. The difference is...
12
by: gigi | last post by:
How to send more than one value using response redirect? For example i can send one like this response.Redirect "pregled.asp?ime=" & strUserName but how to send two or more values? I tried...
1
by: =?Utf-8?B?R2F2?= | last post by:
Hi all, I'm trying to force downloads from my page specifically for some powerpoint and jpeg files. using the following code: Response.ContentType= "APPLICATION/OCTET-STREAM"; string...
2
by: Nathan Sokalski | last post by:
I have an application in which I want to allow users to view certain files that are on the server, but not part of the application. To do this, I figured I would have ASP.NET read the files and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.