Home  >  Article  >  Web Front-end  >  What are the methods of javascript file object

What are the methods of javascript file object

青灯夜游
青灯夜游Original
2021-07-19 18:14:162451browse

The methods of the javascript file object include: "CopyFile(source,destination)", DeleteFile(), MoveFile(), OpenTextFile(), iomode(), format(), etc.

What are the methods of javascript file object

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

To operate files in the browser, in most cases the File object is used, obtained from the <input type='file' /> element, and then continue the operation (for example, The selected image is displayed on the page, the file is uploaded to the server using ajax, etc.). Here we introduce the API related to operating files in the browser

methods of javascript file objects

##obj.CopyFile(source,destination[,overwrite]) source: source file ##obj.DeleteFile(file,[force])Delete the specified file or folder obj: file or folder force: optional, boolean value, if the read-only attribute is set to be deleted file or folder, it is true, otherwise it is falseobj.MoveFile(Source, Destination)Cut the specified file or folder from a location Switch to another locationSource: file or folderobj.OpenTextFile(FileName, IOMode, Create, Format)Open the specified file and return a TextStream object.                                                                                                                                                                                                                                      
methods Description ##Remarks
Copy the specified file or folder from one location to another obj: file or folder destination: required, copy the file Or the destination location of the folder
overwrite: optional. Overwrite is true, otherwise it is false, and the default is true

file: file to be deleted

Destination: the destination location to move the file or folder
Read, write or append the file through this object FileName: should be the name of the File object
IOMode: Optional, the specified input/output mode, which can be one of three constants:
IOMode One to specify the format of the open file,
If omitted, the file will be opened in ASCII format



##iomode()

Constant0Open the file in read-only mode and cannot write to this fileForWriting1 Open the file in writing mode. If a file with the same name exists, its previous content will be overwritten.ForAppend8Open the file and Start writing from the end of the file
Value Description ForReading
format()

##constant

ValueDescriptionUse system Default value is openOpen in Unicode modeOpen in ASCII mode[Recommended learning: ]
TristateUseDefault-2
TristateTrue -1
TristateFalse 0
javascript advanced tutorial

The above is the detailed content of What are the methods of javascript file object. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn