probs.. image from file is binary...code seems correct..help
Posted: Tue Jan 27, 2004 10:38 am
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();
?>
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();
?>