Re: showing submitted images

From: Date: Tue, 21 Aug 2001 22:56:37 +0000
Subject: Re: showing submitted images
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63807@lists.php.net to get a copy of this message
A FORM submission is supposed to return an HTML document, not a JPEG. Have your return document look more like this: echo "<IMG SRC=display.php?pathname=$form_data_name>"; Then, move your header() and fread into the display.php file. The catch is the file is DELETED after the upload script finishes. So what you *REALLY* need to do is use http://php.net/copy_uploaded_file first and pass the new home of that file into your display script. If that infobar is being spewed out before your headers, though, you'll have to dink around some more, and *MAYBE* even go so far as to name your display.php script /screwy/display.jpeg, and have an .htaccess file in /screwy that makes JPEG get parsed by PHP. Your actual JPEGs then, should *NOT* go in /screwy/ but some place where they are just regular old jpeg files... You may be able to avoid that by using: echo "<IMG SRC=display.php/fakeoutinfobar.jpeg/pathame=$form_data_name>" PHP and Apache will ignore that bogus fakeoutinfobar.jpeg in there, but infobar will probably see this URL as a JPEG and not output the HTML. -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: Simon Lysbjerg Hansen <lysbjerg@worldonline.dk> Newsgroups: php.general To: <php-general@lists.php.net> Sent: Sunday, August 19, 2001 5:24 PM Subject: showing submitted images > Please help, > > I'm trying to submit a .jpg image via a html form and showing it with the > following piece of code > > <?php > if ($submit) { > header("Content-type: $form_data_type"); > $data = fread(fopen($form_data, "r"), filesize($form_data)); > echo $data; > } > else { > ?> > <form method="post" action="<?php echo $PHP_SELF ?>" > enctype="multipart/form-data"> > <INPUT TYPE="hidden" name="MAX_FILE_SIZE" > value="1000000"> > <br>File to show:<br> > <input type="file" name="form_data" size="40"> > <p><input type="submit" name="submit" > value="submit"> > </form> > <?php > } > ?> > > but I only get the binary contents of the .jpg file. What's wrong? > > My hostmaster has an infobar running at the top of my page [check > www.oss-fodbold.dk to see what I mean]. Is this the problem? > > Thanks in advance > > Simon > >

« previous php.general (#63807) next »