I investigate the problem of file upload using html5, and I have theoretical question: has html5 any limits for file size for uploading? For example, can I upload files with size ~500Gb?
P.S.: I use FileReader api for reading file.
Ok. This problem is resolved.
But as it explains in FileReader API:
This interface provides methods to read File objects or Blob objects into memory...
As I understood correctly, I can't read file with size which is more than available RAM?
I investigate the problem of file upload using html5, and I have theoretical question: has html5 any limits for file size for uploading? For example, can I upload files with size ~500Gb?
P.S.: I use FileReader api for reading file.
Ok. This problem is resolved.
But as it explains in FileReader API:
This interface provides methods to read File objects or Blob objects into memory...
As I understood correctly, I can't read file with size which is more than available RAM?
Share Improve this question edited Feb 19, 2015 at 13:36 Mike Mameko asked Feb 19, 2015 at 11:38 Mike MamekoMike Mameko 3191 gold badge3 silver badges11 bronze badges 2- stackoverflow./questions/20706418/… – pawel Commented Feb 19, 2015 at 11:45
- @pawel I also saw that and was going to flag as duplicate, but as it not got a answer it wouldn't allow it. It's a shame answer's can't be voted upon – atmd Commented Feb 19, 2015 at 11:47
2 Answers
Reset to default 6Nope, there is no size upload limit.
here is the spec and here is a related question on how to check the file size, so that you can add limits if you like.
It's worth pointing out that if you are looking to store the file on the server, you might hit file upload limits/restrictions there. But you should be able to configure them. i.e. php/wordpress default upload limit
Hope this useful..
Form,script for validating:
<form action="check.php" method="post" enctype="multipart/form-data">
<label>Upload An Image</label>
<input type="file" id="file_upload" name="file_upload" />
<input type="submit" onClick="return validate()" name="upload"/>
</form>
<script>
function validate(){
var size=2097152;
var file_size=document.getElementById('file_upload').files[0].size;
if(file_size>=size){
alert('File too large');
return false;
}
var type='image/jpeg';
var file_type=document.getElementById('file_upload').files[0].type;
if(file_type!=type){
alert('Format not supported,Only .jpeg images are accepted');
return false;
}
}
php for uploading:
<?php
if(isset($_POST['upload'])){
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["file_upload"]["name"]);
if(move_uploaded_file($_FILES["file_upload"]["tmp_name"], $target_file)){
echo "The file ". basename( $_FILES["file_upload"]["name"]). " has been uploaded.";
}
else{
echo "sorry";
}
}
?>