Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
70
rated 0 times [  75] [ 5]  / answers: 1 / hits: 62091  / 14 Years ago, mon, july 19, 2010, 12:00:00

Is it possible to determine if the user has selected a file for a particular input type=file field using javascript/jQuery?



I have developed a custom fieldtype for ExpressionEngine (PHP-based CMS) that lets users upload and store their files on Amazon S3, but the most popular EE hosting service has set a max_file_uploads limit of 20. I'd like to allow the user to upload 20 files, edit the entry again to add 20 more, etc. Unfortunately upon editing the entry the initial 20 files have a replace this image file input field that appears to be knocking out the possibility of uploading new images. I'd like to remove any unused file input fields via javascript when the form is submitted.


More From » php

 Answers
21

Yes - you can read the value and even bind to the change event if you want.



<html>
<head>
<title>Test Page</title>
<script src=http://code.jquery.com/jquery-latest.js></script>
<script type=text/javascript>
$(function()
{
$('#tester').change( function()
{
console.log( $(this).val() );
});
});
</script>
</head>

<body>

<input type=file id=tester />

</body>
</html>


But there are other, multiple-upload solutions that might suit your needs better, such as bpeterson76 posted.


[#96181] Friday, July 16, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
catrinas

Total Points: 587
Total Questions: 100
Total Answers: 105

Location: Rwanda
Member since Thu, Feb 10, 2022
2 Years ago
;