![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Newbie
Join Date: Mar 2007
Posts: 15
Rep Power: 0
![]() |
Well the problem with you solution is I have to redo whatever I do to make the image which seems inefficient.
Here's my code from a wider view: class Bundle{
var $something, $or, $other, $image, $image_type;
//constructor
function Bundle($a){
if (is_array($a)){
foreach ($a as $k=>$v){
$this->$k = $v;
}
elsif (is_int($a)){
//get the object from database
}
}
//class method
function show(){
echo "<h1>Hi There". $this->something."</h1>";
echo "<img src="image.php?bundle=".$this->something";
}
}
///// end class
image.php
$i = $_GET['bundle']
$bundle = new Bundle($i);
header ("Content-type: "$bundle->image_type);
echo($bundle->image);$b = new Bundle(7); $b->show(); $something = $_POST['something'];
$or = $_POST['or'];
$other = $_POST['other'];
$type = $_FILES['image']['type'];
$image = fread(fopen($_FILES['image']['tmp_name'], "r"), $_FILES['image']['size'));
$a = array('something'=>$something,
'or'=>$or,
'other'=>$other,
'image'=> $image,
'image_type'=>$type);
$bundle = new Bundle($a);
$bundle->show();I suppose below could be a compromise: class Bundle{
var $something, $or, $other, $image, $image_type;
//constructor
function Bundle($a){
if (is_array($a)){
foreach ($a as $k=>$v){
$this->$k = $v;
}
elsif (is_int($a)){
//get the object from database
}
}
//class method
function show(){
echo "<h1>Hi There". $this->something."</h1>";
if (isset($this->image_file){
echo "<img src=".$this->image_file.">";}
else
echo "<img src="image.php?bundle=".$this->something";
}
}
///// end class
////from form
$something = $_POST['something'];
$or = $_POST['or'];
$other = $_POST['other'];
$type = $_FILES['image']['type'];
$image = fread(fopen($_FILES['image']['tmp_name'], "r"), $_FILES['image']['size'));
$image_file = temp_nam();
$i = fopen($image_file, "w");
fwrite($i, $image);
$a = array('something'=>$something,
'or'=>$or,
'other'=>$other,
'image'=> $image,
'image_type'=>$type,
'image_file'=>$image_file);
$bundle = new Bundle($a);
$bundle->show();so that a temp fil is writen if not from database. I still say, there should be a way I can sen the raw data directly to a file. |
|
|
|
|
|
#12 |
|
Programmer
Join Date: Mar 2007
Posts: 39
Rep Power: 0
![]() |
I don't believe there is a way. The image needs its own header information.
Your uploads, do you store them in the database? If so, could you just get them from there? |
|
|
|
|
|
#13 | |
|
Newbie
Join Date: Mar 2007
Posts: 15
Rep Power: 0
![]() |
Quote:
There's two stages. 1) Creating them from a form and checking and proofing them before comitting them to the database. For this stage I can make and refer to temp files. 2) once committed to DB I can use call the image from the database. A neat tidyness is that I can call "unlink" on the temp files at precisely the same time as committing them to the database. It's a fix. It'll work. I don't really like it, though. Seems redundant. But it definately will work. |
|
|
|
|
![]() |
| 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 |