simple php picture upload code PHP upload Image generation
<?php
$zpname =addslashes (isset ($_post[' zpname ')) $_post[' Zpname ']: ');
$zpurl =isset ($_post[' Zpurl '])? $_post[' Zpurl ']: ';
$zpsay =addslashes (isset ($_post[' Zpsay ')) $_post[' Zpsay ']: ');
$blueidea =isset ($_post[' Blueidea '])? $_post[' Blueidea ']: ';
$up _path= ". /zp/";
$up _size=100000;
$up _name=md5 (Date ("Y:m:d h:i:s"));
$up _type=$_files[' file ' [' type '];
$up _exten= "Start:image/gifimage/pjpegimage/x-png";
echo $up _type;
Echo (Strrpos ($up _exten, $up _type));
Exit ();
= $up _wh[' mime '];
$up _sava= ';
Echo ($_files[' file '] [' size ']);
Echo ($_files[' file '] [' type ']);
Exit ();
if ($zpname = = "" | | $zpname >50) {
Echo (' <script>alert (' work name cannot be empty or greater than 50 characters! '); History.back ();</script> ");
Exit ();
}
if (!ereg ("^ (http|https|ftp) \://" (([a-za-z0-9\-]+\.) {1,} [A-za-z] {2,4}) | (localhost)) (: [0-9]+) {0,1} (/[a-za-z0-9\-\_\,\./\+&%\ $#\=~]+) *$ ", $zpurl))" {
echo ("<script>alert URL not valid!"); History.back ();</script> ");
Exit ();
}
if ($zpsay = = "" | | $zpsay >500) {
Echo ("<script>alert (' synopsis cannot be empty or more than 500 characters! '); History.back ();</script> ");
Exit ();
}
if (Strrpos ($up _exten, ' image/x-png ')) {
$up _sava= $up _path. $up _name. PNG ';
}
if (Strrpos ($up _exten, ' image/pjpeg ')) {
$up _sava= $up _path. $up _name. JPG ';
}
if (Strrpos ($up _exten, ' image/gif ')) {
$up _sava= $up _path. $up _name. GIF ';
}
if ($up _sava== ') {
Echo ("Sorry, you upload the wrong type, only allow uploading. gif jpg. png"); History.back ();</script> "); <script>alert
Exit ();
}
if ($_files[' file '] [' Size ']> $up _size) {
Echo ("<script>alert (' upload file cannot be greater than 100K '); History.back ();</script>");
Exit ();
}
/*print_r ($up _wh[' mime ');
exit ();
if ($up _wh[0]>300 | | $up _wh>400 | | $up _wh[0]<93 | | $up _wh<63) {
echo ("<script>alert" Picture width 93-300, height 400-63 '); History.back ();</script> "); exit ();
}
*/
if (move_uploaded_file ($_files[' file '] [' tmp_name '], $up _sava)) {
up_insert ($zpname, $zpurl, $zpsay, $blueidea, $up _name. " GIF ');
echo (' upload succeeded '); location= '. $_server[' Http_referer ']. "'; </script> ");
}else{
echo ("<script>alert (' unknown error '); History.back ();</script>");
}
Function Up_insert ($zpname, $zpurl, $zpsay, $blueidea, $up _filename) {
$up _sava= "zp/". $up _filename;
connect ();
mysql_query ($sql) or Die (' Insert into data fail: '. mysql_error ());
}