Simple php Image Upload code-PHP source code

Source: Internet
Author: User
Tags file url
Ec (2); simple php Image Upload code php Upload Image Generation & lt ;? Php $ zpnameaddslashes (isset ($ _ POST [zpname])? $ _ POST [zpname] :); $ zpurlisset ($ _ POST [zpurl])? $ _ POST [zpurl]:; $ zpsayaddslashes (isset ($ _ POST [zpsay])? Script ec (2); script

Simple php Image Upload codePhp uploads Image Generation


$ Zpname = addslashes (isset ($ _ POST ['zpname'])? $ _ POST ['zpname']: '');
$ Zpurl = isset ($ _ POST ['zpurl'])? $ _ POST ['zpurl']: '';
$ Zpsay = addslashes (isset ($ _ POST ['zpasse'])? $ _ POST ['zcopy']: '');
$ 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 ('the file name cannot be blank or more 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 ('invalid File URL! '); History. back (); script ");
Exit ();
}
If ($ zpsay = "" ||$ zpsay> 500 ){
Echo ("script" alert ('the file description cannot be blank or exceed 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 ')){
Upload up_sava?$up_path.$up_name.'.gif ';
}
If ($ up_sava = ''){
Echo ("script" alert ('Sorry, your upload type is incorrect. Only upload is allowed. gif. jpg. png '); history. back (); script ");
Exit ();
}
If ($ _ FILES ['file'] ['SIZE']> $ up_size ){
Echo ("script" alert ('upload file cannot exceed 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 ('image between 93-300 in width and between 400-63 in height '); history. back (); script "); exit ();
}
*/
If (move_uploaded_file ($ _ FILES ['file'] ['tmp _ name'], $ up_sava )){
Up_insert($zpname,$zpurl,$zpsay,$blueidea,$up_name.'.gif ');
Echo ("script" alert ('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.