JavaScript DHTML/Development/File Upload

Материал из Web эксперт
Перейти к: навигация, поиск

File Input Element

   <source lang="html4strict">

<HTML> <HEAD> <TITLE>FileUpload Object</TITLE> </HEAD> <BODY> <FORM METHOD="POST" ACTION="yourCGIURL" ENCTYPE="multipart/form-data"> File to be uploaded:

<INPUT TYPE="file" SIZE=40 NAME="fileToGo">

<INPUT TYPE="button" VALUE="View Value" onClick="alert(this.form.fileToGo.value)"> </FORM> </BODY> </HTML> </source>

Methods and Properties of the FileUpload Object

   <source lang="html4strict">
 Method

blur() Removes focus from the FileUpload box. focus() Sets focus on the FileUpload box. handleEvent() Invokes the default handler for the specified event. select() Selects input area for the FileUpload box. Property name Contains the value of the name attribute for the FileUpload box. form Reference the Form object containing the FileUpload box. type Contains the value of the type attribute for the FileUpload box. value String specifying the pathname of the selected file.

      </source>
   
  


Viewing File Dates

   <source lang="html4strict">

<HTML> <HEAD> <TITLE>file Created Date and file Modified Date Properties</TITLE> <SCRIPT LANGUAGE="JavaScript"> function fillInBlanks() {

   var created = document.fileCreatedDate;
   var modified = document.fileModifiedDate;
   document.all.created.innerText = created;
   document.all.modified.innerText = modified;
   
   var createdDate = new Date(created).getTime();
   var today = new Date().getTime();
   var diff = Math.floor((today - createdDate) / (1000*60*60*24));
   
   document.all.diff.innerText = diff;
   document.all.size.innerText = document.fileSize;

} </SCRIPT> </HEAD> <BODY onLoad="fillInBlanks()">

fileCreatedDate and fileModifiedDate Properties


<P>This file (  bytes) was created on   and most

recently modified on  .

It has been   days since this file was created.

</BODY> </HTML>

      </source>