Need help with retrieving images...coding is correct according to tutorials

This is a discussion on Need help with retrieving images...coding is correct according to tutorials within the PHP Language forums, part of the PHP Programming Forums category; Can someone tell me what I am missing? I have looked at a ton of tutorials about retrieving images as ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-27-2004
lifeAfter76
 
Posts: n/a
Default Need help with retrieving images...coding is correct according to tutorials

Can someone tell me what I am missing? I have looked at a ton of
tutorials about retrieving images as an image instead of binary from a
file.
I have verified the image goes into the file perfect.

Thanks in advance

<?PHP
require_once('common.php');
session_start();

startFormHeader();

$name = $_FILES['userfile']['name'];

$size = $_FILES['userfile']['size'];
$tempFile = $_FILES['userfile']['tmp_name'];
if ($userfile=='none')
{
echo "Problem: no file uploaded";
exit;
}

if ($size==0)
{
echo "Problem: uploaded file is zero length";
exit;
}

if (!is_uploaded_file($userfile))
{
echo "problem: possible file upload attack";
exit;
}


$upfile ='showVehicle/'.$userfile_name;

$copy = copy($_FILES['userfile']['tmp_name'],"showVehicle/".$name);


if(!$copy)
echo "System error: was not able to load image";
else
echo"File uploaded successfully<br><br>";



$grab = "showVehicle/".$name;
$fp = fopen($grab, "rb");
$contents = fread($fp, filesize($grab));

fclose($fp);


footer();
?>
Reply With Quote
  #2 (permalink)  
Old 01-27-2004
CountScubula
 
Posts: n/a
Default Re: Need help with retrieving images...coding is correct according to tutorials

I didnt really look at your code becouse I do not understand the question,
you verified the image goes into a file, so whats the problem?

--
Mike Bradley
http://www.gzentools.com -- free online php tools
"lifeAfter76" <lifeafter76@yahoo.com> wrote in message
news:1fae5b12.0401270825.1a72352@posting.google.co m...
> Can someone tell me what I am missing? I have looked at a ton of
> tutorials about retrieving images as an image instead of binary from a
> file.
> I have verified the image goes into the file perfect.
>
> Thanks in advance
>
> <?PHP
> require_once('common.php');
> session_start();
>
> startFormHeader();
>
> $name = $_FILES['userfile']['name'];
>
> $size = $_FILES['userfile']['size'];
> $tempFile = $_FILES['userfile']['tmp_name'];
> if ($userfile=='none')
> {
> echo "Problem: no file uploaded";
> exit;
> }
>
> if ($size==0)
> {
> echo "Problem: uploaded file is zero length";
> exit;
> }
>
> if (!is_uploaded_file($userfile))
> {
> echo "problem: possible file upload attack";
> exit;
> }
>
>
> $upfile ='showVehicle/'.$userfile_name;
>
> $copy = copy($_FILES['userfile']['tmp_name'],"showVehicle/".$name);
>
>
> if(!$copy)
> echo "System error: was not able to load image";
> else
> echo"File uploaded successfully<br><br>";
>
>
>
> $grab = "showVehicle/".$name;
> $fp = fopen($grab, "rb");
> $contents = fread($fp, filesize($grab));
>
> fclose($fp);
>
>
> footer();
> ?>



Reply With Quote
  #3 (permalink)  
Old 01-27-2004
Jedi121
 
Posts: n/a
Default Re: Need help with retrieving images...coding is correct according to tutorials

lifeAfter76 a écrit le 27/01/2004 :
[...]
> $grab = "showVehicle/".$name;
> $fp = fopen($grab, "rb");
> $contents = fread($fp, filesize($grab));


Before sending $contents to the webclient, you must tell him it's an
image you're sending him otherwise it will show it as text. So use
header() before sending the file content :

<?php
header("Content-type: image/png"); //Header for a PNG file
echo $contents;
?>


Reply With Quote
  #4 (permalink)  
Old 01-27-2004
Shawn Wilson
 
Posts: n/a
Default Re: Need help with retrieving images...coding is correct according totutorials

lifeAfter76 wrote:
>
> Can someone tell me what I am missing? I have looked at a ton of
> tutorials about retrieving images as an image instead of binary from a
> file.
> I have verified the image goes into the file perfect.
>
> Thanks in advance
>
> <?PHP
> require_once('common.php');
> session_start();
>
> startFormHeader();
>
> $name = $_FILES['userfile']['name'];
>
> $size = $_FILES['userfile']['size'];
> $tempFile = $_FILES['userfile']['tmp_name'];
> if ($userfile=='none')
> {
> echo "Problem: no file uploaded";
> exit;
> }
>
> if ($size==0)
> {
> echo "Problem: uploaded file is zero length";
> exit;
> }
>
> if (!is_uploaded_file($userfile))
> {
> echo "problem: possible file upload attack";
> exit;
> }
>
> $upfile ='showVehicle/'.$userfile_name;
>
> $copy = copy($_FILES['userfile']['tmp_name'],"showVehicle/".$name);
>
> if(!$copy)
> echo "System error: was not able to load image";
> else
> echo"File uploaded successfully<br><br>";
>
> $grab = "showVehicle/".$name;
> $fp = fopen($grab, "rb");
> $contents = fread($fp, filesize($grab));
>
> fclose($fp);
>
> footer();
> ?>


Unless I'm missing something, you haven't described the problem. Please tell us
what the problem is and what, if any error messages you get. If your script
works in some cases, but not others, let us know and note the differences.

Shawn
--
Shawn Wilson
shawn@glassgiant.com
http://www.glassgiant.com
Reply With Quote
  #5 (permalink)  
Old 01-27-2004
Agelmar
 
Posts: n/a
Default Re: Need help with retrieving images...coding is correct according to tutorials

lifeAfter76 wrote:
> Can someone tell me what I am missing? I have looked at a ton of
> tutorials about retrieving images as an image instead of binary from a
> file.
> I have verified the image goes into the file perfect.
>
> Thanks in advance
>
> <?PHP
> require_once('common.php');
> session_start();
>
> startFormHeader();
>
> $name = $_FILES['userfile']['name'];
>
> $size = $_FILES['userfile']['size'];
> $tempFile = $_FILES['userfile']['tmp_name'];
> if ($userfile=='none')


$userfile is not defined anywhere...


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:27 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0