473,767 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

readfile and images

I'm trying to replace <IMG SRC="some image"> with the usage of readfile, but
without luck. I have seen examples like this:

header ('Content-length: ' .filesize($imag e_file));
header ('Content-type: image/jpeg');
readfile ($image_file);

This works OK unless you have modified the header before. What I like to do
is to display the image *within* HTML codes, something like:

<HTML><HEADER>b lablabla</HEADER><BODY>
<?php
echo "This is image $image_file:<BR >";
readfile ($image_file);
?>

But if I try to use the readfile as show above, I only get garbage... (as
expected). So... how can I replace a <IMG..> statement with the use of
readfile?

--
Jørn Dahl-Stamnes
http://www.dahl-stamnes.net/dahls/
Jan 24 '06 #1
1 9447
Jørn Dahl-Stamnes wrote:
I'm trying to replace <IMG SRC="some image"> with the usage of readfile,
but without luck. I have seen examples like this:

header ('Content-length: ' .filesize($imag e_file));
header ('Content-type: image/jpeg');
readfile ($image_file);

This works OK unless you have modified the header before. What I like to
do is to display the image *within* HTML codes, something like:

<HTML><HEADER>b lablabla</HEADER><BODY>
<?php
echo "This is image $image_file:<BR >";
readfile ($image_file);
?>

But if I try to use the readfile as show above, I only get garbage... (as
expected). So... how can I replace a <IMG..> statement with the use of
readfile?


I got it... I have to use <IMG SRC=some-php-script.php?arg= filename> and
then use the code shown at the top.

--
Jørn Dahl-Stamnes
http://www.dahl-stamnes.net/dahls/
Jan 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8741
by: Phil Powell | last post by:
class DownloadGenerator { var $fullFilePath; function DownloadGenerator($fullFilePath) { $this->fullFilePath = $fullFilePath; } function &generateForceDownloadHeaders($fullFilePath = '') { // STATIC VOID METHOD
7
14255
by: deko | last post by:
I need to allow users to download files from a directory that is not publicly accessible. To do this, I use a download script: header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=".$filename); readfile($fullpath); I've also tried using header("Content-Type: application/force-download") instead of header("Content-Type: application/octet-stream"), but get the same results - the downloaded...
12
6901
by: ORC | last post by:
Shouldn't 'ReadFile' block when timeouts are specified even when running in overlapped mode or am I wrong ??? Thanks Ole
15
22315
by: Jameson | last post by:
Happy New Year, Everyone! I am trying to figure out how to display a bunch of images (mainly JPEGs, but possibly a few GIFs and PNGs as well) that are stored in a local directory on the system. I can do this with the glob() function, but I can't seem to put in a directory other than one within the webroot. For example, I can only put "/uploads" and not "/Volumes/jray/Pictures...". Any ideas how to get around this? If I can't use the...
10
13414
by: eholz1 | last post by:
Hello Members, I am setting up a photo website. I have decided to use PHP and MySQL. I can load jpeg files into the table (medium blob, or even longtext) and get the image(s) to display without a problem. I am using chunk_split(data) and the base64_encode and base64_decode on the files. I do a select from the database, and then echo the image (with header(Content Type: image/jpeg) and the decoded image displays fine. Yes, I have...
4
3551
by: dgiglio | last post by:
Hi, For security purposes, I am trying to make an image appear on my page from outside of the web root. It works in two files, both of which I have taken from a book and modified. The first file (display.php) is actually the page which displays the image, and the second file (show_image.php) takes the file out of the web root and sends it to the first file. All the images I am trying to access are gifs. Simple enough, or so it would seem... ...
5
1342
by: cbmeeks | last post by:
I have a photo sharing site that takes a photo once it is uploaded and copies it to a NON browsable location so that it can not be browsed directly. Then, when you want to view it, I load it in PHP and send down the custom header. That way, I can control security, bandwidth, etc. Works great. However, it's very demanding and it simply can't serve the data as quickly as a static image in a browsable location.
4
13990
by: Eric Renken | last post by:
I am trying to do an Overlapped ReadFile on a HID device and it just isn't working for me. The WaitForSingleObject keeps giving me an error "The system cannot find the file specified." This code need to work in 64bit and 32bit, so I am using IntPtr for pointers instead of int. Here is the structure of OVERLAPPED public struct OVERLAPPED
15
5944
by: Ketchup | last post by:
Hello everyone, I have been stuck with this problem for quite some time now. I am working in VB.NET, using framework 1.0. I have to keep the compatibility down to the original .NET framework as much as possible. I am forced to use API calls for several functions, one of which is ReadFile. The reason is because the framework seems to use ANSI versions of all API functions, limiting the MAX_PATH for filenames to about 260 chars for ...
0
9404
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,...
0
10009
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 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...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9838
tracyyun
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...
0
8835
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
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();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.