Mailinglisten-Archive |
Hi,
keine Ahnung was ich da alles spielt,... Wenn ihr nur bestimmen wollt ob es jpeg oder gif ist nehmt einfach
$cert1 = "image/pjpeg"; //Jpeg type 1
$cert2 = "image/jpeg"; //Jpeg type 2
$cert3 = "image/gif"; //Gif type
Vor dem Hochladen einfach ne If Abfrage machen!
Oder hier nen fertigs Script!
<?
//user defined variables
require ("shared/config/config.inc.php");
//all image types to upload
$cert1 = "image/pjpeg"; //Jpeg type 1
$cert2 = "image/jpeg"; //Jpeg type 2
$cert3 = "image/gif"; //Gif type
$cert4 = "image/ief"; //Ief type
$cert5 = "image/png"; //Png type
$cert6 = "image/tiff"; //Tiff type
$cert7 = "image/bmp"; //Bmp Type
$cert8 = "image/vnd.wap.wbmp"; //Wbmp type
$cert9 = "image/x-cmu-raster"; //Ras type
$cert10 = "image/x-x-portable-anymap"; //Pnm type
$cert11 = "image/x-portable-bitmap"; //Pbm type
$cert12 = "image/x-portable-graymap"; //Pgm type
$cert13 = "image/x-portable-pixmap"; //Ppm type
$cert14 = "image/x-rgb"; //Rgb type
$cert15 = "image/x-xbitmap"; //Xbm type
$cert16 = "image/x-xpixmap"; //Xpm type
$cert17 = "image/x-xwindowdump"; //Xwd type
$log = "";
//begin upload 1
//checks if file exists
if ($img_name == "") {
$log .= "Es wurde kein Bild ausgewählt!<br>";
}
if ($img_name != "") {
//checks if file exists
if (file_exists("$abpath/$id.jpg")) {
$log .= "Bild ist bereits hochgeladen.<br>";
} else {
//checks if files to big
if (($sizelim == "yes") && ($img_size > $size)) {
$log .= "Bild ist zu gross.<br>";
} else {
//Checks if file is an image
if (($img_type == $cert1) or ($img_type == $cert2) or ($img_type == $cert3) or ($img_type == $cert4) or ($img_type == $cert5) or ($img_type == $cert6) or ($img_type == $cert7) or ($img_type == $cert8) or ($img_type == $cert9) or ($img_type == $cert10) or ($img_type == $cert11) or ($img_type == $cert12) or ($img_type == $cert13) or ($img_type == $cert14) or ($img_type == $cert15) or ($img_type == $cert16) or ($img_type == $cert17)) {
_(at)_copy($img, "$abpath/$id.jpg") or $log .= "Konnte Bild nicht auf den Server übertragen.<br>";
if (file_exists("$abpath/$id.jpg")) {
$log .= "Bild wurde auf den Server übertragen.<br>";
}
} else {
$log .= "Die Datei ist kein Bild.<br>";
}
}
}
}
?>
$abpath ist in der Config definiert,... Kann relativer oder absoluter sein! Kann man aber auch direkt angeben!
Mit $sizelim könnt ihr auch noch eine maximal Grösse fest legen!
Und:
<form method=POST action=imgu.php enctype=multipart/form-data>
<input type=file name=img size=30>
<input type="hidden" name="id" value="<? echo "$id"?>">
<input type="submit" name="submit" value="Upload">
Is das Formular!
Müsste alles so gehen! Bei Fragen/Probs einfach mailen!
Greets Exe
php::bar PHP Wiki - Listenarchive