PHP Upload File Code instance

The code is as follows Copy Code File Upload ?Require './global.php ';$updir = "Uploaddir";$form? $form = $form: $form = "Form1";if (! $inputname) $inputname =$_get[' InputName '];if ($uploadfile) {$copyfilename =date (' Ymdhis ',

PHP Read and write file operation

function Read ($filename, $filesze){$FP =fopen ($filename, "RB");//Fopen RB property read file and unlock with flock Lock_sh,lock_unif ($FP){Flock ($FP, lock_sh);Clearstatcache ();$filesize =filesize ($filename);if ($filesize >0){$data =fread ($fp, $

PHP Determines whether it is a number

/*In PHP, we use the is_numeric and Intval functions to determine whether the user has entered a numeric or numeric string.*/ $num = 1;$num 1 = ' 1 ';$STR = ' abc '; if (Is_numeric ($num)){echo $num. ' is a digital type ';}1 is the digital type

PHP custom generated random cipher function

?//Turns out to be zend.com, by Hunter Reproducted / *Usage: $ new_password = Return_password ();Example: Generate Password: 2X5BJJ2Z,ERGID62Y,P2SHTDPV* / The code is as follows Copy Code function Return_password () { /

How PHP creates a file instance code

*/ The code is as follows Copy Code $FN = ' Www.111cn.net.txt '$fcon = ' How PHP creates a file '; Contentif ($f =fopen ($FN, "w")){if (fwrite ($f, $fcon)){Echo ' Write a file successfully ';}Else{echo ' File not

Practical methods for static variables of PHP static keywords (1/3)

The code is as follows Copy Code Class Foo{public static $my _static = ' foo ';Public Function Staticvalue () {Return self:: $my _static;}}Class Bar extends Foo{Public Function foostatic () {Return Parent:: $my _static;}}Print Foo:: $

Using php to generate thumbnails [recommended]

Function ResizeImage ($ im, $ maxwidth, $ maxheight, $ name ){$ Width = imagesx ($ im );$ Height = imagesy ($ im );If ($ maxwidth & $ width> $ maxwidth) | ($ maxheight & $ height> $ maxheight )){If ($ maxwidth & $ width> $ maxwidth ){$ Widthratio = $

Php scales according to the specified size to generate a thumbnail of the uploaded image

In the php Tutorial, upload image thumbnails are generated by proportional scaling of the specified size./***** Proportional scaling* @ Param unknown_type $ srcImage source image path* @ Param unknown_type $ toFile target Image path* @ Param unknown_

Php creates a directory, deletes folders, finds illegal directories, and deletes

// $ Pattern = "/file-([0-2] d {3})-([1-9] d ?) /"; This regular expression captures the month and day of the folder and further judges and processes the folder.02 for ($ I = 2005; $ I 03 {04 for ($ j = 1; $ j 05 {06 $ dest_dir = "text/file-". $ I. "

Php saves a two-dimensional array to a one-dimensional array tutorial

$ Array = array (Array (1, 2 ),Array (3, 4 ),Array ('www .111cn.net ', '111cn. Net '));    // See the two-dimensional data structure above. We will use foreach for the example below.Function array_2to1 ($ array){ Static $ result_array = array

Php unlimited classification function

 Ar = array (0 => array ('name' => 'food', 'id' => 1, 'Pi' => 0 ),02 1 => array ('name' => 'plant ', 'id' => 2, 'pid' => 0 ),03 3 => array ('name' => 'cabbage ', 'id' => 3, 'pid' => 1 ),04 4 => array ('name' => 'tree', 'id' => 4, 'pid '=> 2 ),05 5 =>

PHP object-oriented final class and final method

Fatal error: Class SuperMath may not inherit from final class (Math) in E: PHPProjects est. php Tutorial on line 14// Declare a final class MathClass Math {Public static $ pi = 3.14;Public function _ toString (){Return "this is the Math class. ";}

Php file download instance code

Function xiazai ($ file_dir, $ file_name)// Parameter description:// File_dir: Directory of the file// File_name: file name{$ File_dir = chop ($ file_dir); // remove unnecessary spaces in the path// Obtain the path of the object to be downloadedIf ($

Php large file download program [http cache negotiation, Etag tag, resumable Upload]

002 $ file_path = './download/download_cn.rar ';003004 // Usage005 downFile ($ file_path );006007 // server file path, download file name (default: Server file name), permit user download method (optional by default), speed limit (automatically by

Php imports db3 data collected by the locomotive to dedecms

$ Path = "d: pdoSpiderResult. db3 ";$ Conn = new PDO ("sqlite: $ path ");$ Array = array ('','','');If ($ conn) {// Echo ('connection pdo success '); }Else {Echo ('cnnection pdo fail, plase check database server! '); }$ Count = 0;$ Sp = new

Php regular expressions in Chinese and English

Php regular expression in Chinese and EnglishHttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> php regular expressions in Chinese and English Function funcChinese ($ str, $ num1 = '', $ num2 ='') // judge Chinese regular expressions {If ($

Php batch file directory creation method

Class newFold {Var $ upload_dir = date ("Y/m/d ");If (! Is_dir ($ this-> upload_dir )){$ This> mkdir_r ($ this-> upload_dir, 0777 ); }Function mkdir_r ($ dirName, $ rights = 0777 ){$ Dirs = explode ('/', $ dirName );$ Dir = '';Foreach ($ dirs as $

Php generates excel xls documents

Method 1-use the HTTP headerAs described in MS Word, you need to format HTML/PHP pages using Excel-friendly CSS and header informationAdd to Your PHP script.Header ("Content-type: application/vnd. ms-excel ");Header ("Content-Disposition: attachment?

Php judges the file upload type and filters insecure data

This function filters insecure charactersFunction s_addslashes ($ string, $ force = 0 ){If (! Get_magic_quotes_gpc ()){If (is_array ($ string )){Foreach ($ string as $ key => $ val ){$ String [$ key] = s_addslashes ($ val, $ force );   }} Else {$

Ajax + php second-level linkage menu code

Ajax + php second-level linkage menu code ajax + php second-level linkage menu code Category 1 Category 2 Php processing codeHeader ("Content-type: text/html; charset = GBK"); // output encoding to avoid Chinese garbled characters$ Pid = $ _ GET [

Total Pages: 12780 1 .... 9401 9402 9403 9404 9405 .... 12780 Go to: GO

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.