Determine whether the local file size selected by the user is legal

xiaoxiao2021-03-06  42

/ ** * Determine whether the local file size selected by the user is legal. * Fileobj: Upload the file object. * Title: Illegal prompt information. * MaxSize: Maximum limitations. * / Function FileSizeCheck (fileobj, title, maxsize) {if (fileobj == null || fileobj.value == ") Return True;

VAR FSO, F, S; Try {fso = new activXObject ("scripting.filesystemObject");} Catch (e) {Alert ("To use the function of the upload file, select: Tool --- Internet Options - - Safety - Custom Level, then "initialize the ActiveX control without marking secure and script" setting to "Enable"); Return False;}

IF (! fso.fileexists) {alert ("File" fileobj.value "Cannot find, please re-select"); fileobj.focus (); return false;}

f = fso.getfile (fileobj.value);

If (f.size> maxsize) {alert (Title "exceeds the maximum limit value:" maxSize / 1024 "k"); fileobj.focus (); return false;}

Return True;}

Ayuan

9CBS certified blog expert

Blog expert

Huawei old employees

Big Data

More than ten years, in Huawei, Internet Corporation's experience, profound understanding and practical experience in CRM, big data, mainly sharing various project experience, including architecture, Java, big data and other articles

转载请注明原文地址:https://www.9cbs.com/read-47564.html

New Post(0)