Hallo an Allllleeeee
Folgendes Problem:
WIe kann ich es realizieren, daß bei der Funktion Bild Upload, ein Standard NoPic Bild eingesetzt wird, wenn ein User kein Bild upgeloadet hat.
Ich habe jetzt schon einige Foren durchforstet und auch schon ein bissl selbst experimentiert, aber meine PHP Kenntnisse reichen wohl dafür nicht aus.
Ich vermute, dass man dazu die FALSE Abfrage verwendet, aber wie und wo baue ich sie ein?
Der Bildupload wird mit 2 Scripts erledigt.
1x das Formular "add.php"
Hier der Ausschnitt des Codes:
und upload_class.php
Vielleicht hat jemand einen Tipp, würde mich sehr freuen.
Danke im Voraus
George
Folgendes Problem:
WIe kann ich es realizieren, daß bei der Funktion Bild Upload, ein Standard NoPic Bild eingesetzt wird, wenn ein User kein Bild upgeloadet hat.
Ich habe jetzt schon einige Foren durchforstet und auch schon ein bissl selbst experimentiert, aber meine PHP Kenntnisse reichen wohl dafür nicht aus.
Ich vermute, dass man dazu die FALSE Abfrage verwendet, aber wie und wo baue ich sie ein?
Der Bildupload wird mit 2 Scripts erledigt.
1x das Formular "add.php"
Hier der Ausschnitt des Codes:
PHP:
if (C_CHECK_REGISTER == '0') $cst = 7;
elseif (C_CHECK_REGISTER == '2') $cst = 1;
else $cst = 0;
$picture = array('', '', '', '', '');
if ((C_PHOTOR) && ((empty($HTTP_POST_FILES['file0']['name'])) && (empty($HTTP_POST_FILES['file1']['name'])) && (empty($HTTP_POST_FILES['file2']['name'])) && (empty($HTTP_POST_FILES['file3']['name'])) && (empty($HTTP_POST_FILES['file4']['name'])))) $errors .= $w[41].'<br>';
if ($errors == '')
{
////////////// Include class for file uploading!
include_once 'classes/upload.class.php';
//////////////
$time = time();
for($p = 0; $p <= 4; $p++)
{
$file = 'file'.$p;
$k = $p+1;
if (!empty($HTTP_POST_FILES[$file]['name']))
{
if (!C_IMG_ERR)
{
// If Unavailable image upload errors with UIN
$dir = date("mY", $time);
$slash = "/";
if (!file_exists(C_PATH.'/members/uploads/'.$dir))
{
umask(0);
mkdir (C_PATH."/members/uploads/".$dir, 0777);
}
}
else $dir = $slash = "";
$fb = date("dHis", $time);
$fe = rand(0, 999);
$fn = $fb."-".$fe;
$intpic = $dir.$slash.$fn.'.';
$u = new Upload($file, C_MAXSZ, C_MAXWD, C_MAXHG, C_PATH.'/members/uploads/'.$intpic);
if (!$u->do_upload()) $errors .= $u->getErrors().'<br>';
$picture[$p] = $intpic.$u->getType();
}
}
mysql_query("INSERT INTO ".C_MYSQL_MEMBERS." VALUES ('','".$fname."','".$lname."','".$pass."',
'".$year."-".$month."-".$day."','".$gender."',
'".$purpose."','".$country."','".$email."','".$url."',
'".$icq."','".$aim."','".$phone."','".$city."','".$adres."','".$marstat."','".$child."','".$height."','".$weight."','".$hcolor."','".$ecolor."','".$etnicity."','".$religion."','".$smoke."','".$drink."','".$education."','".$job."','".$hobby."','".$descr."','".$sgender."','".$setnicity."','".$sreligion."','".$agef."','".$aget."','".$heightf."','".$heightt."','".$weightf."','".$weightt."','".$hdyfu."','".$picture[0]."','".$picture[1]."','".$picture[2]."','".$picture[3]."','".$picture[4]."','".horo($month, $day)."',NOW(''),NOW(''),INET_ATON('".ip()."'),'".$cst."','0')") or die(mysql_error());
$last_id = mysql_fetch_array(mysql_query("SELECT LAST_INSERT_ID() AS last_id"));
$last_id = $last_id['last_id'];
$codegen = code_gen();
if ((C_CHECK_REGISTER == '1') || (C_CHECK_REGISTER == '3'))
{
$str = $w[42];
mysql_query("INSERT INTO ".C_MYSQL_TEMP." VALUES ('".$last_id."',NOW(''),'".$codegen."')");
sendmail(C_ADMINM, $email, $w[43], $w[44].C_URL.'/check.php?id='.$last_id.'&code='.$codegen, 'text');
}
elseif(C_CHECK_REGISTER == '2')
{
$str = $w[45];
}
elseif(C_CHECK_REGISTER == '0')
{
if (C_ID == '2') $last_id = $email;
$str = $w[46].$last_id.$w[47].$pass;
}
printm($str);
}
else
{
mes($w[290].'<p align=left>'.$errors.'</p>');
}
}
?>
<script language="JavaScript">
<!--
function formCheck(form) {
<?if (C_FIRSTNR) {$tm=array(C_FIRSTNS,C_FIRSTNB);?>
if (form.fname.value == "")
{alert("<?=template($w[3],$tm)?>");return false;}
<?}?>
<?if (C_LASTNR) {$tm=array(C_LASTNS,C_LASTNB);?>
if (form.lname.value == "")
{alert("<?=template($w[4],$tm)?>");return false;}
<?}?>
if (form.pass.value == "")
<?$tm=array(C_PASSS,C_PASSB);?>
{alert("<?=template($w[6],$tm)?>");return false;}
if (form.rpass.value == "")
{alert("<?=$w[48]?>");return false;}
if (form.pass.value != form.rpass.value)
{alert("<?=$w[49]?>");return false;}
<?if (C_BIRTHR) {?>
if ((form.month.selectedIndex=="")||(form.day.selectedIndex=="")||(form.year.selectedIndex==""))
{alert("<?=$w[5]?>");return false;}
<?}?>
<?if (C_GENDR) {?>
if (form.gender.selectedIndex=="")
{alert("<?=$w[7]?>");return false;}
<?}?>
<?if (C_SGENDR) {?>
if (form.sgender.selectedIndex=="")
{alert("<?=$w[8]?>");return false;}
<?}?>
<?if (C_PURPR) {?>
if (form.purpose.selectedIndex=="")
{alert("<?=$w[9]?>");return false;}
<?}?>
<?if (C_CNTRR) {?>
if (form.country.selectedIndex=="")
{alert("<?=$w[10]?>");return false;}
<?}?>
if (form.email.value == "")
{alert("<?=$w[11]?>");return false;}
<?if (C_PHONER) {?>
if (form.phone.value == "")
{alert("<?=$w[15]?>");return false;}
<?}?>
<?if (C_CITYR) {?>
if (form.city.value == "")
{alert("<?=$w[16]?>");return false;}
<?}?>
//<?if (C_ADRESR) {?>
//if (form.adres.value == "")
//{alert("<?=$w[400]?>");return false;}
<?}?>
<?if (C_MARSR) {?>
if (form.marstat.selectedIndex=="")
{alert("<?=$w[17]?>");return false;}
<?}?>
<?if (C_CHILDR) {?>
if (form.child.selectedIndex=="")
{alert("<?=$w[18]?>");return false;}
<?}?>
<?if (C_HGHTR) {?>
if (form.height.selectedIndex=="")
{alert("<?=$w[19]?>");return false;}
<?}?>
<?if (C_WGHTR) {?>
if (form.weight.selectedIndex=="")
{alert("<?=$w[20]?>");return false;}
<?}?>
<?if (C_HAIRR) {?>
if (form.hcolor.selectedIndex=="")
{alert("<?=$w[23]?>");return false;}
<?}?>
<?if (C_EYER) {?>
if (form.ecolor.selectedIndex=="")
{alert("<?=$w[24]?>");return false;}
<?}?>
<?if (C_ETNR) {?>
if (form.etnicity.selectedIndex=="")
{alert("<?=$w[25]?>");return false;}
<?}?>
<?if (C_RELR) {?>
if (form.religion.selectedIndex=="")
{alert("<?=$w[26]?>");return false;}
<?}?>
<?if (C_SETNR) {?>
if (form.setnicity.selectedIndex=="")
{alert("<?=$w[27]?>");return false;}
<?}?>
<?if (C_SRELR) {?>
if (form.sreligion.selectedIndex=="")
{alert("<?=$w[28]?>");return false;}
<?}?>
<?if (C_SMOKER) {?>
if (form.smoke.selectedIndex=="")
{alert("<?=$w[29]?>");return false;}
<?}?>
<?if (C_DRINKR) {?>
if (form.drink.selectedIndex=="")
{alert("<?=$w[30]?>");return false;}
<?}?>
<?if (C_EDUCR) {?>
if (form.education.selectedIndex=="")
{alert("<?=$w[31]?>");return false;}
<?}?>
<?if (C_JOBR) {?>
if (form.job.value=="")
{alert("<?=$w[32]?>");return false;}
<?}?>
<?if (C_HOBBR) {?>
if (form.hobby.value=="")
{alert("<?=$w[35]?>");return false;}
<?}?>
if (form.descr.value=="")
{alert("<?=$w[38]?>");return false;}
<?if (C_HDYFUR) {?>
if (form.hdyfu.selectedIndex=="")
{alert("<?=$w[34]?>");return false;}
<?}?>
<?if (C_PHOTOR) {?>
if ((form.file0.value=="")&&(form.file1.value=="")&&(form.file2.value=="")&&(form.file3.value=="")&&(form.file4.value==""))
{alert("<?=$w[41]?>");return false;}
<?}?>
if (document.form.submit.action != "") {
document.form.submit.disabled=1;}
}
// -->
</script>
und upload_class.php
PHP:
<?
class Upload {
var $up_file;
var $f;
var $p;
var $name;
var $size;
var $widht;
var $height;
var $type;
var $max_size;
var $path;
var $directory;
var $errors;
var $move;
function Upload($input_name,$size,$width,$height,$dir) {
$this->f = $input_name;
$this->max_size = $size;
$this->directory = $dir;
$this->max_width = $width;
$this->max_height = $height;
}
function do_upload() {
//global $_FILES;
$this->up_file = $_FILES[$this->f]['tmp_name'];
$this->name = $_FILES[$this->f]['name'];
$this->size = $_FILES[$this->f]['size']/1000;
$this->type = $_FILES[$this->f]['type'];
if (ereg(".gif$", $this->type)) $this->type="gif";
elseif(ereg(".png$", $this->type)) $this->type="png";
elseif(ereg(".jpg$", $this->type)||
ereg(".jpeg$", $this->type)) $this->type="jpg";
else $this->type="";
$this->path = $this->directory;
$this->width = $this->height = '';
if(!empty($this->up_file)&&(C_HACK3)) {
$this->p = getimagesize($this->up_file);
$this->width = $this->p[0];
$this->height = $this->p[1];
}
$this->errors = '';
if($this->move_file()) return true;
else return false;
}
function getName() {
return $this->name;
}
function getMaxSize() {
return $this->max_size;
}
function getSize() {
return $this->size;
}
function getType() {
return $this->type;
}
function move_file() {
if($this->check_size() && $this->check_extension() && $this->check_uploaded() && $this->check_wh()) {
$this->move = move_uploaded_file($this->up_file, $this->path.$this->type);
chmod($this->path.$this->type, 0644);
return true;
} else {
return false;
}
}
function check_size() {
global $w;
if(($this->up_file != "")&&($this->size <= $this->max_size)) {
return true;
} else {
if($this->errors == '') {
$tm=array($this->max_size,$this->size);
$this->errors = $this->errors.template($w[220],$tm);
}
return false;
}
}
function check_wh() { // Check width and height
global $w;
if(($this->up_file != "")&&($this->width <= $this->max_width)&&($this->height <= $this->max_height)) {
return true;
} else {
if($this->errors == '') {
$tm=array($this->max_width,$this->max_height);
$this->errors = $this->errors.template($w[2201],$tm);
}
return false;
}
}
function check_uploaded() {
global $w;
if(is_uploaded_file($this->up_file)) {
return true;
} else {
if($this->errors == '') {
$this->errors = $this->errors.$w[1].'4';
}
return false;
}
}
function check_extension() {
global $w;
if ($this->type == "") {
if($this->errors == '') {
$this->errors = $this->errors.$w[222].$this->type;
}
return false;
} else {
return true;
}
}
function getErrors() {
return $this->errors;
}
}
?>
Vielleicht hat jemand einen Tipp, würde mich sehr freuen.
Danke im Voraus
George