trcontent
Legacy Member
Hallo
ik heb een upload script, maar als je geen foto selecteerd maar gewoon op uload drukt, dan komt er een witte pagina. Hoe kan ik daar dan een error op laten komen zoald bv : kies een foto voor dat je kan uploaden.
dit is mijn script :
<?
include "config.php";
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$ms) {
echo "Your File Size is too big, please reduce the size and try again.<br>\n"; exit; }
if(($HTTP_POST_FILES['userfile']['type']=="image/gif") ||
($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") ||
($HTTP_POST_FILES['userfile']['type']=="image/jpg") ||
($HTTP_POST_FILES['userfile']['type']=="image/jpg") ||
($HTTP_POST_FILES['userfile']['type']=="image/bmp") ||
($HTTP_POST_FILES['userfile']['type']=="image/JPEG") ||
($HTTP_POST_FILES['userfile']['type']=="image/png")) {
if (file_exists("./".$path . $HTTP_POST_FILES['userfile']['name'])) {
echo "File name exists please rename then try again.<br>\n"; exit; }
$zufall = rand(1,99999);
$fupl = "$zufall";
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], "./" .$path .$fupl .$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "Upload Failed, please try again<br>\n"; exit; } else {
?>
<br>
<?php
//set url variable
$domst = "";
$drecks = "/";
$imgf = $fupl.$HTTP_POST_FILES['userfile']['name'];
$thbf = $imgf;
$urlf = $domst .$drecks .$path .$imgf;
//create thumbnails
function LoadWBMP($imgname)
{
$im = @imagecreatefromwbmp($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreatetruecolor (20, 20); /* Create a blank image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 10, 10, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
?>
dankje
Michael
ik heb een upload script, maar als je geen foto selecteerd maar gewoon op uload drukt, dan komt er een witte pagina. Hoe kan ik daar dan een error op laten komen zoald bv : kies een foto voor dat je kan uploaden.
dit is mijn script :
<?
include "config.php";
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$ms) {
echo "Your File Size is too big, please reduce the size and try again.<br>\n"; exit; }
if(($HTTP_POST_FILES['userfile']['type']=="image/gif") ||
($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") ||
($HTTP_POST_FILES['userfile']['type']=="image/jpg") ||
($HTTP_POST_FILES['userfile']['type']=="image/jpg") ||
($HTTP_POST_FILES['userfile']['type']=="image/bmp") ||
($HTTP_POST_FILES['userfile']['type']=="image/JPEG") ||
($HTTP_POST_FILES['userfile']['type']=="image/png")) {
if (file_exists("./".$path . $HTTP_POST_FILES['userfile']['name'])) {
echo "File name exists please rename then try again.<br>\n"; exit; }
$zufall = rand(1,99999);
$fupl = "$zufall";
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], "./" .$path .$fupl .$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "Upload Failed, please try again<br>\n"; exit; } else {
?>
<br>
<?php
//set url variable
$domst = "";
$drecks = "/";
$imgf = $fupl.$HTTP_POST_FILES['userfile']['name'];
$thbf = $imgf;
$urlf = $domst .$drecks .$path .$imgf;
//create thumbnails
function LoadWBMP($imgname)
{
$im = @imagecreatefromwbmp($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreatetruecolor (20, 20); /* Create a blank image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 10, 10, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
?>
dankje
Michael
