Simple PHP picture upload code

Source: Internet
Author: User

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\-\_\,\./\+&amp;%\ $#\=~]+) *$ ", $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 ());
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.