Follow me to learn oracle php (59)

Error handling

Tools , an error is detected, the error information is recorded.

Require error, only by Jumplines controller action, the error message output

 

Tools :

 

 

Record message :

 

 

By the return value, determination execution result. If the failure by the tool object getError () method to get the error message!

In the controller:

Back/GoodsController->insertAction();

 

 

Tip:

All of the tools, you can use a similar program processing error messages!

 

Error type

Error element indicates an error , and type

0,123,467 possible values

0 means no error

1 : The file is too large, greater than php configuration

 

2 : The file is too large , more than the form elements max_file_size

 

Tip: currently is server PHP judgment.

However :

PHP is proposed, it is desirable, when the file is too large, when the browser requests can use this value to judge the size of the

 

3 : upload part files .

4 : There is no upload files.

5 : Logically, empty file upload (length 0 )

6 : did not find a temporary upload directory (access control) .

7 : temporary file write failed ( disk space, permissions).

 

Configuration upload temporary directory:

 

 

 

A request for the number of files can be uploaded:

 

 

 

POST presence data maximum limits:

 

 

 

Multiple File Upload

A request existence of multiple files.

Forms of file name field attribute naming, resulting in $ _FILES of different structures :

 

Name property values independently different: represents the logical  multiple files no contact!

 

Each uploaded file to generate a $ _FILES of elements , were treated to:

 

 

Name array mode using the name: Logic upload an association

 

 

After submitting the $ _FILES of the structure:

The file information within a group of all, to organize a $ _FILES element within the element also has 5 Ge ( name , of the type , tmp_name , size , error ) elements. Each inner element is an array to store all the names, types, and so on:

 

There is no way to directly get information about a file:

We need to find ways to piece together information for each uploaded file, one by one treatment:

Traversing any of these properties (name, error), acquiring the current file Key (flag) , using the same Key , obtain additional information about the current file (from other attributes in common . 5 th to)

 

 

Directory operation

 

Create a directory

Mkdir ( directory address, permissions, whether to create a recursive = false);

 

 

Delete Contents

Rmdir (directory address )

 

You can only delete empty directories. (Does not support recursive delete)

 

Mobile ( renamed)

Rename (old address, new address )

 

 

This function also supports file operations .

 

 

Get directory contents (files)

Open Directory directory handle  = opendir (directory address )

Directory handle: PHP a directory between programs and links .

 

In turn read the directory within the file filename = readdir (directory handle);

Sequentially reading a file (subdirectory), while moving down the handle pointer. If the reading is less than the return false !

Directory memory in two logical subdirectories ., .. respectively represent the current directory and the parent directory!

 

By mating loop structure  to complete all of the files in the directory reads:

 

Processing File Name :

 

 

Close directory closedir ()

 

 

 

Recursive get directory contents

Open a directory

In order to read the paper catalog

If a file is a directory

Recursively the directory using open, read, judge this recursive grass

 

Recursive point : If the sub-file is a directory, recursively

Export : If the subdirectory does not exist in the directory, you do not need to continue recursively!

 

 

 

Tree Display

Using a specific amount of indentation to achieve the purpose of the tree!

The core problem, calculation requires indentation number!

Indent level, and a recursive call is consistent depth . Whenever execution Yi Ji recursive operation , the indentation level of files found +1;

Syntax achieve:

Increase a parameter indicating the depth of the current level of function calls, recursion whenever +1;

 

 

Nesting

 

Using multi -dimensional nested arrays, represent a hierarchical relationship!

For example :

 

 

Realization :

 

 

 

Recursive delete

Unlink (file address ) to delete the file.

 

 

 

 

Directory file name encoding problem:

Show , the operating system encoding to encode the response data.

GBK Windows , project utf-8

 

 

Code exist Chinese addresses: the need converted to a coding system in order to be recognized by the system file:

 

Guess you like

Origin www.cnblogs.com/RighTgraM/p/10971463.html