![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Mar 2007
Posts: 15
Rep Power: 0
![]() |
Let's suppose I capture a bunch of raw data to a variable.
For example: //page.php $photo = fread(fopen($_FILES[$str]['tmp_name'], "r"), $_FILES[$str]['size']); $photo_type = $_FILES[$str]['type']; or //page.php
$query = "SELECT photo FROM messages WHERE id = $id";
$conn = connect();
$result = $conn->query($query);
while ($row = $result->fetchRow()){$image = $row[0];}Okay, so let's suppose I've got $photo (a huge long string of data) and I've got $photo_type (the mime type for whatever type of image it is). Now I could display this as an image by doing: //page.php
$photo = fread(fopen($_FILES[$str]['tmp_name'], "r"), $_FILES[$str]['size']);
$photo_type = $_FILES[$str]['type'];
header('Content-Type: $photo_type);
$photo;That's all fine and good but I don't want page.php to be the image itself. I want it to have the image in it as an <img> tag like: //page.php $photo = fread(fopen($_FILES[$str]['tmp_name'], "r"), $_FILES[$str]['size']); $photo_type = $_FILES[$str]['type']; ?> Hello <?= $name ?><br> <img src="<? some code to render image ?> I've made the following workaround: //page.php
$photo = fread(fopen($_FILES[$str]['tmp_name'], "r"), $_FILES[$str]['size']);
$photo_type = $_FILES[$str]['type'];
$_SESSION['binary'] = $photo;
$_SESSION['type'] = $type;
?>
Hello <?= $name ?><br>
<img src="image.php">
//image.php
get_session();
header("Content-Type: $_SESSION['type']");
$_SESSION['binary'];Do I actually have to pass the data? The reason for the HTML code <img src=url> is simply to make an http request and recieve the response. Is there any way I can use PHP to bypass the request entirely and give the response (which would be "Content-Type: $type\n\n$photo") directly? Any help appreciated, wooz |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| GOTO Sys. Tray Src. (code Snippet) | Cipher | Show Off Your Open Source Projects | 1 | Oct 17th, 2006 1:38 PM |
| Jackpot game | zorin | Visual Basic | 3 | Jun 10th, 2005 1:19 PM |
| Help in QBASIC (I think it's similar to VB) | phoenix987 | Visual Basic | 3 | May 9th, 2005 12:33 PM |
| Help with a QBASIC program | phoenix987 | Other Programming Languages | 4 | May 5th, 2005 12:27 PM |