Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Mar 18th, 2007, 3:58 PM   #11
woozy
Newbie
 
Join Date: Mar 2007
Posts: 15
Rep Power: 0 woozy is on a distinguished road
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);
The above works okay if I must to something like:
$b = new Bundle(7);
$b->show();
but I'm still stuck when I get the image from a 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'));
$a = array('something'=>$something,
               'or'=>$or,
               'other'=>$other,
               'image'=> $image,
              'image_type'=>$type);
$bundle = new Bundle($a);
$bundle->show();
won't work at all. So far as I can tell there is no way to make show work as I'd have to pass all the same info to image.php.

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.
woozy is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:55 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC