File Upload

File Upload ជា​ធាតុ HTML ម៉្យាង​ដែល​អនុញ្ញាត​អោយ​យើង​អាច upload ​ឯកសារ​នានា​ទៅ​ទុក​នៅ​លើ server សំរាប់​ការប្រើប្រាស់​នៅ​លើ​បណ្តាញ Internet ។ យើង​អាច​បង្កើត​ទំរង់បែបបទ​នៃ File Upload ដូច​ខាង​ក្រោម​នេះ៖
<!DOCTYPE html>
<html>
  <head>
    <link href='https://fonts.googleapis.com/css?family=Odor+Mean+Chey' rel='stylesheet'>
  </head>
  <body style="font:14px/1.5 'Odor Mean Chey'">
  
  	
<script> function validateForm() { var valf = document.forms["myForm"]["ffile"].value; if(valf == ""){ alert("អ្នកត្រូវ​ជ្រើសរើស​យកឯកសារ​ណាមួយ​​។"); return false; } } </script> </body> </html>



នៅ​លើ​បន្ទាត់​លេខ 9 គឺ​ជា​ការបង្កើត​ធាតុ HTML មួយ​ដែល​មាន​ប្រភេទ​ជា File Uoload ដែល​អនុញ្ញាត​អោយ​យើង​អាច upload ឯកសារ​គ្រប់​ប្រភេទ​ទៅ​ទុក​នៅ​លើ server ។ ហើយ​បើ​យើង​ចង់ upload ឯកសារ​ជា​ច្រើន​ក្នុង​ពេល​តែ​មួយ យើង​ត្រូវ​ថែម​សម្បត្តិ​ម្យ៉ាង (attribute) ដែល​ជា​ពាក្យ​ថា multiple ចូល​ទៅ​ក្នុង​នោះ​ (<input type="file" id="myfile" name="ffile" multiple >) ៕

Input FileUpload Object Properties
Property Description
accept Sets or returns the value of the accept attribute of the file upload button
autofocus Sets or returns whether a file upload button should automatically get focus upon page load
defaultValue Sets or returns the default value of the file upload button
disabled Sets or returns whether the file upload button is disabled, or not
files Returns a FileList object that represents the file or files selected with the file upload button
form Returns a reference to the form that contains the file upload button
multiple Sets or returns whether a user is allowed to select more than one file in the file upload field
name Sets or returns the value of the name attribute of the file upload button
required Sets or returns whether a file in the file upload field must be selected before submitting a form
type Returns which type of form element the file upload button is
value Returns the path or the name of the selected file