Hi!
Really need help, dont know whats wrong :(
I am trying to show images using php script, it works fine, pictures
are shown,
but if i right click on it and choose "save picture as" it offers me to
save it as "untitled.b mp",
not jpeg the picture actually is :(
And if i do save it and then check it - it is actually bmp image, not
jpeg (it has bmp header)
Could you help please, i need to be able to save it as jpeg, using
"save picture as".
here is the script:
<?php
if ($_REQUEST['img'])
{
$showfile = $_REQUEST['img'];
if (file_exists($s howfile))
{
header("content-type: image/jpeg");
header('Content-Length: ' . filesize($showf ile));
$mfile = fopen($showfile , 'rb');
fpassthru($mfil e);
fclose($mfile);
}
}
echo "<img src='?img=1.jpg '>";
?>
Thanks a lot! 9 10694 b0****@gmail.co m wrote: header("content-type: image/jpeg");
header("Content-Type: image/jpeg");
header('Content-Disposition: inline; filename=$showf ile");
Allthough, Disposition isn't really according to standards....
A brutal read: http://www.faqs.org/rfcs/rfc2616
Also, readfile($showf ile) seems faster in this case....
Grtz,
--
Rik Wasmus
Thank you very much!
works great! but now i have a different problem, my actual script has
session_start() ; at the top,
and it still showing "save picture as" as "untitled.b mp" :(
if i delete session_start() it shows jpeg, if i add session_start - it
shows untitled.bmp :(
Can you copy all the code?
RainCT wrote: Can you copy all the code?
Sure, here it is:
<?php
session_start() ;
$dir = session_id();
if ($_REQUEST['img'])
{
$showfile = "./temp/$dir/".$_REQUEST['img'];
if (file_exists($s howfile))
{
header("content-type: image/jpeg");
header('Content-Length: ' . filesize($showf ile));
header("Content-Disposition: inline; filename=$showf ile");
readfile($showf ile);
}
}
echo "<img src='?img=1.jpg '>";
?>
If i keep session_start() "Save picture as" detects image as
untitled.bmp, if i delete
session_start() - everythng is fine, it is detected as jpeg, but i need
session_id(), so i have to start session...
And, i read somewhere in this group that i should add ini_set, like
this:
<?php
ini_set('sessio n.use_cookies', '0');
ini_set('sessio n.cache_limiter ', '');
ini_set('sessio n.cache_expires ', '');
session_start() ;
$dir = session_id();
.....
When i do that the image type is detected correctly as jpeg, but the
file name is not, its named as the script, showimg.jpg,
filename=$showf ile" is not working for some reason. But i guess its
good enough, it would be nice to detect the file name as well though b0****@gmail.co m wrote: RainCT wrote:
Can you copy all the code?
Sure, here it is:
<?php session_start() ; $dir = session_id();
if ($_REQUEST['img']) { $showfile = "./temp/$dir/".$_REQUEST['img'];
if (file_exists($s howfile)) { header("content-type: image/jpeg"); header('Content-Length: ' . filesize($showf ile)); header("Content-Disposition: inline; filename=$showf ile"); readfile($showf ile); } } echo "<img src='?img=1.jpg '>"; ?>
If i keep session_start() "Save picture as" detects image as untitled.bmp, if i delete session_start() - everythng is fine, it is detected as jpeg, but i need session_id(), so i have to start session... And, i read somewhere in this group that i should add ini_set, like this:
<?php ini_set('sessio n.use_cookies', '0'); ini_set('sessio n.cache_limiter ', ''); ini_set('sessio n.cache_expires ', ''); session_start() ; $dir = session_id(); ....
When i do that the image type is detected correctly as jpeg, but the file name is not, its named as the script, showimg.jpg, filename=$showf ile" is not working for some reason. But i guess its good enough, it would be nice to detect the file name as well though
But earlier you said this really is a bmp, not a jpg.
Just changing the name or header is not going to change the real file type. It
will still be a bmp. If you want to change it to a jpg, you need to convert it
first.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
Jerry Stuckle wrote: b0****@gmail.co m wrote: RainCT wrote:
Can you copy all the code?
Sure, here it is:
<?php session_start() ; $dir = session_id();
if ($_REQUEST['img']) { $showfile = "./temp/$dir/".$_REQUEST['img'];
if (file_exists($s howfile)) { header("content-type: image/jpeg"); header('Content-Length: ' . filesize($showf ile)); header("Content-Disposition: inline; filename=$showf ile"); readfile($showf ile); } } echo "<img src='?img=1.jpg '>"; ?>
If i keep session_start() "Save picture as" detects image as untitled.bmp, if i delete session_start() - everythng is fine, it is detected as jpeg, but i need session_id(), so i have to start session... And, i read somewhere in this group that i should add ini_set, like this:
<?php ini_set('sessio n.use_cookies', '0'); ini_set('sessio n.cache_limiter ', ''); ini_set('sessio n.cache_expires ', ''); session_start() ; $dir = session_id(); ....
When i do that the image type is detected correctly as jpeg, but the file name is not, its named as the script, showimg.jpg, filename=$showf ile" is not working for some reason. But i guess its good enough, it would be nice to detect the file name as well though
But earlier you said this really is a bmp, not a jpg.
Just changing the name or header is not going to change the real file type. It will still be a bmp. If you want to change it to a jpg, you need to convert it first.
Yes, i understand that. The picture is jpeg (echo "<img
src='?img=1.jpg '>";), but "save picture as" only offered to save it as
bmp, not jpeg, that was my problem/question. b0****@gmail.co m wrote: Jerry Stuckle wrote:
b0****@gmail. com wrote:
RainCT wrote:
Can you copy all the code?
Sure, here it is:
<?php session_star t(); $dir = session_id();
if ($_REQUEST['img']) { $showfile = "./temp/$dir/".$_REQUEST['img'];
if (file_exists($s howfile)) { header("content-type: image/jpeg"); header('Content-Length: ' . filesize($showf ile)); header("Content-Disposition: inline; filename=$showf ile"); readfile($showf ile); } } echo "<img src='?img=1.jpg '>"; ?>
If i keep session_start() "Save picture as" detects image as untitled.bmp , if i delete session_star t() - everythng is fine, it is detected as jpeg, but i need session_id() , so i have to start session... And, i read somewhere in this group that i should add ini_set, like this:
<?php ini_set('ses sion.use_cookie s', '0'); ini_set('ses sion.cache_limi ter', ''); ini_set('ses sion.cache_expi res', ''); session_star t(); $dir = session_id(); ....
When i do that the image type is detected correctly as jpeg, but the file name is not, its named as the script, showimg.jpg, filename=$sh owfile" is not working for some reason. But i guess its good enough, it would be nice to detect the file name as well though
But earlier you said this really is a bmp, not a jpg.
Just changing the name or header is not going to change the real file type. It will still be a bmp. If you want to change it to a jpg, you need to convert it first.
Yes, i understand that. The picture is jpeg (echo "<img src='?img=1.jpg '>";), but "save picture as" only offered to save it as bmp, not jpeg, that was my problem/question.
OK, I misread your original post. I understand now.
I haven't actually tried mixing session_start() with header(); normally if I'm
using header() I don't need session_start() .
Since both must be sent before anything else is output, I suspect there's a
conflict between the two. However, what should work is to use an img tag in
this file, pointing at a file containing your PHP code. In this file send your
session_start() ; in the other file only send the header and image.
This works because the img tag causes another request to the server, which
requires another header.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
Jerry Stuckle wrote: b0****@gmail.co m wrote: Jerry Stuckle wrote:
b0****@gmail. com wrote:
RainCT wrote:
>Can you copy all the code?
Sure, here it is:
<?php session_star t(); $dir = session_id();
if ($_REQUEST['img']) { $showfile = "./temp/$dir/".$_REQUEST['img'];
if (file_exists($s howfile)) { header("content-type: image/jpeg"); header('Content-Length: ' . filesize($showf ile)); header("Content-Disposition: inline; filename=$showf ile"); readfile($showf ile); } } echo "<img src='?img=1.jpg '>"; ?>
If i keep session_start() "Save picture as" detects image as untitled.bmp , if i delete session_star t() - everythng is fine, it is detected as jpeg, but i need session_id() , so i have to start session... And, i read somewhere in this group that i should add ini_set, like this:
<?php ini_set('ses sion.use_cookie s', '0'); ini_set('ses sion.cache_limi ter', ''); ini_set('ses sion.cache_expi res', ''); session_star t(); $dir = session_id(); ....
When i do that the image type is detected correctly as jpeg, but the file name is not, its named as the script, showimg.jpg, filename=$sh owfile" is not working for some reason. But i guess its good enough, it would be nice to detect the file name as well though
But earlier you said this really is a bmp, not a jpg.
Just changing the name or header is not going to change the real file type. It will still be a bmp. If you want to change it to a jpg, you need to convert it first.
Yes, i understand that. The picture is jpeg (echo "<img src='?img=1.jpg '>";), but "save picture as" only offered to save it as bmp, not jpeg, that was my problem/question.
OK, I misread your original post. I understand now.
I haven't actually tried mixing session_start() with header(); normally if I'm using header() I don't need session_start() .
Since both must be sent before anything else is output, I suspect there's a conflict between the two. However, what should work is to use an img tag in this file, pointing at a file containing your PHP code. In this file send your session_start() ; in the other file only send the header and image.
This works because the img tag causes another request to the server, which requires another header.
Thank you very much!
It sounds like a great idea, i don't fully understand how its going to
work, but ill figure it out.
My main concern is to be able to hide the actual path to the image file
($showfile = "./temp/$dir/".$_REQUEST['img'];) so it would not be
anywhere in the html, and to make sure the file can only be downloaded
once, by the person with the correct session id b0****@gmail.co m wrote: Jerry Stuckle wrote:
b0****@gmail. com wrote:
Jerry Stuckle wrote:
b0****@gmai l.com wrote:
>RainCT wrote: > > > >>Can you copy all the code? > > >Sure, here it is: > ><?php >session_st art(); >$dir = session_id(); > >if ($_REQUEST['img']) >{ >$showfil e = "./temp/$dir/".$_REQUEST['img']; > > if (file_exists($s howfile)) > { > header("content-type: image/jpeg"); > header('Content-Length: ' . filesize($showf ile)); > header("Content-Disposition: inline; filename=$showf ile"); > readfile($showf ile); > } >} >echo "<img src='?img=1.jpg '>"; >?> > >If i keep session_start() "Save picture as" detects image as >untitled.b mp, if i delete >session_st art() - everythng is fine, it is detected as jpeg, but i need >session_id (), so i have to start session... >And, i read somewhere in this group that i should add ini_set, like >this: > ><?php >ini_set('s ession.use_cook ies', '0'); >ini_set('s ession.cache_li miter', ''); >ini_set('s ession.cache_ex pires', ''); >session_st art(); >$dir = session_id(); >.... > >When i do that the image type is detected correctly as jpeg, but the >file name is not, its named as the script, showimg.jpg, >filename=$ showfile" is not working for some reason. But i guess its >good enough, it would be nice to detect the file name as well though >
But earlier you said this really is a bmp, not a jpg.
Just changing the name or header is not going to change the real file type. It will still be a bmp. If you want to change it to a jpg, you need to convert it first.
Yes, i understand that. The picture is jpeg (echo "<img src='?img=1. jpg'>";), but "save picture as" only offered to save it as bmp, not jpeg, that was my problem/question.
OK, I misread your original post. I understand now.
I haven't actually tried mixing session_start() with header(); normally if I'm using header() I don't need session_start() .
Since both must be sent before anything else is output, I suspect there's a conflict between the two. However, what should work is to use an img tag in this file, pointing at a file containing your PHP code. In this file send your session_start (); in the other file only send the header and image.
This works because the img tag causes another request to the server, which requires another header.
Thank you very much! It sounds like a great idea, i don't fully understand how its going to work, but ill figure it out. My main concern is to be able to hide the actual path to the image file ($showfile = "./temp/$dir/".$_REQUEST['img'];) so it would not be anywhere in the html, and to make sure the file can only be downloaded once, by the person with the correct session id
With this method you can't hide the URL completely. You'll still have the path
to the php file in the img tag. But you should be able to now add some code to
the php file which will limit access to the image.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== === This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gequina |
last post by:
Something goes wrong in my script. I'm all new to it so i don't know
much yet.
I have a set of buttons. And when you click on either of them, the
background image will change. Only it's not working. It works when i
click on one, but then when i want to click on another, it's not
working.
What am i doing wrong?
thanks in advance
|
by: StvyLife |
last post by:
okay when you visit www.msn.com
is show a slide shoe with three cylce of two picture and I picture/texc
combo split screen with links.
I think that is cool; I would like to to make one like that.
can someone help in making something like that.
other ones a little bit boring to me; they have their link out side the box.
thanks
|
by: Change PH to F... |
last post by:
I am working on some code that is currently in javascript that I would
like to be able to do in CSS if possible and 100% eliminate JS. At the
URL http://www.aerosmithfans.com/index2.html there is a series of 4 CD
cover images with a scroll button on each side. When the user clicks
the button, the selection of the four CD covers changes. Is there a way
to code this so that it is purely CSS and no JS what-so-ever? If so can
someone...
|
by: Larry |
last post by:
Hi all,
Does anyone here can teach me how to capture the print out or a printer into
a image? What actually I wanna do is to capture the print out and save into
a richtextbox.
Appreciate for any comments or approaches..!
Larry
|
by: Mitchell Vincent |
last post by:
I've been trying to get a standard toolbar to play nice with some nice icons
that I have. When I put them on a button or anything they look perfect, but
through an imagelist and on a toolbar they all have this blue aura around
them. I assume that is from the transparency, but I don't understand why
almost any other control displays them properly.. There really is no
replacement for the toolbar (without paying!), so I hope someone can tell...
| |
by: shivmuni |
last post by:
Hi All,
I want integrate help with my application .
I drop HelpProvider control on form and assigned TopicId.
On F1 key press I am not able to show help.
Please help me .
Thanks in advance.......................
Shiv
|
by: rodchar |
last post by:
hey all,
i downloaded a clip art from microsoft's office site. i have a web page with
a non-white background. but the image has a white background. is there anyway
to fix this?
thanks,
rodchar
|
by: =?Utf-8?B?VHV4ZWRv?= |
last post by:
I run a server 2003 network and all computers have a network image
folder. I am trying to create and application usuing visual basics
2005 that would allow users to chose photos which they would like to
print and how many copies etc. and this is then saved so that i can
log in view them and then sort them out to be printed. Anyone have any ideas
how to do this? Thanks for any help.
|
by: myusernotyours |
last post by:
Am trying to create a splash screen using the SplashScreen class.
i edit the manifest file to be put in to the jar file and also put the .gif file in the application directory but the method returns null all the time.
Should the .gif file be inside the jar and how do i get it there. Am using netbeans 6 and it automatically builds the jar.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |