To implement flash php image upload, both have their own division of labor:
flash is responsible for opening the browser and browsing my computer;
The flash methods we need here are:
1. FileReference or FileReferenceList class, which is responsible for browsing my computer. The difference between the two is that the former can select one file at a time
And the latter can select multiple files at a time File;
包 | flash.net |
类 | public class FileReference |
继承 | FileReference -> EventDispatcher -> Object |
|
ActionScript 3.0 |
Player version: |
Flash Player 9 |
The
FileReference
包 | flash.net |
类 | public final class FileFilter |
继承 | FileFilter-> Object |
object references a file on the user's disk and has properties that contain information about the file's size, type, name, creation date, modification date, and creator type (Macintosh only) .
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9 |
Package | flash.net |
Class | public final class FileFilter |
Inherits | FileFilter-> Object |
Language version: | ActionScript 3.0 |
Player version: | Flash Player 9 |
The
FileFilter class is used to indicate that when calling <span class="searchhilite"><code>FileReference
.browse() or <span class="searchhilite"><code>FileReference
List.browse() Which files are shown in the file browsing dialog box that appears. The FileFilter instance will be passed to the browse()<code>browse()
function. If a FileFilter instance is used, extensions and file types not specified in the FileFilter instance will be filtered out, i.e. the user cannot select these types when uploading. If no FileFilter object is passed to browse()<code>browse()
, all files will be displayed in the dialog box.
3. These are enough
php is responsible for the background upload. There is only one function in this part, move_uploaded_file
(PHP 4 >= 4.0.3, PHP 5)
move_uploaded_file -- Move the uploaded file to a new locationThis function checks to ensure that the file specified by filename
is a legitimate upload file (i.e. uploaded via PHP's HTTP POST upload mechanism). If the file is legal, it is moved to the file specified by destination
.
If filename
is not a valid uploaded file, no operation will occur and move_uploaded_file() will return FALSE.
If filename
is a legitimate uploaded file but cannot be moved for some reason, no action will occur and move_uploaded_file() will return FALSE. A warning is also issued.
This check is particularly important if the uploaded file may cause its content to be displayed to the user or other users of this system.
Code part: