<!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 |