如何使用jQuery中的“浏览"按钮获取所选文件的值? [英] How to get the value of the selected files using Browse button in jQuery?
本文介绍了如何使用jQuery中的“浏览"按钮获取所选文件的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<div id="image_gallery" class="image_gallery">
<label>Gallery:</label><input type="file" id="gallery" multiple="multiple" name="gallery"><input name="file" type="text" /><br>
</div>
当我使用浏览按钮选择多个文件时,如何在jQuery中获取所有选定的路径或仅获取图像名称,以及如何将这些值发送到PHP文件?
When I select more than one file using browse button, How can I get all the selected paths or only the Image name in jQuery and how can I send those values to a PHP file?
<body>
<h2 align="center">CONTENT MANAGEMENT ADMIN PANEL</h2>
<fieldset class="project-information">
<h2>Create New Project</h2>
<div id="splash-screen" class="splash-screen">
<label>Builder Logo:</label><input type="file" id="logo" name="browse_logo"><br>
<label>Project Name:</label><input type="text" id="project_name" name="project_name"><br>
<label>Background Image:</label><input type="file" id="background_image" name="background_image"><br>
</div>
<div id="overview" class="overview">
<label>Project Overview:</label><textarea id="project_overview" name="project_overview"></textarea><br>
<label>Starts From:</label><input type="text" id="starts_from" name="starts_from"><br>
<label>Built Up Area:</label><input type="text" id="project_area" name="project_area"><br>
<label>Buildings:</label></label><input type="text" id="project_buildings" name="project_buildings"><br>
<label>Bedrooms:</label><input type="text" id="project_bedrooms" name="project_bedrooms"><br>
</div>
<div id="project_features" class="project_features">
<label>Featured Image:</label><input type="file" id="featured_image" name="featured_image"><br>
<label>Features:</label><textarea name="features" id="features" rows="4" cols="100"></textarea>
</div>
<div id="project_aminities" class="project_aminities">
<label>Aminities:</label><input type="checkbox" name="aminities">some text1
<input type="checkbox" class="aminities" value="1" name="aminities">some text2
<input type="checkbox" class="aminities" name="aminities">some text3
<input type="checkbox" class="aminities" name="aminities">some text4
<input type="checkbox" class="aminities" name="aminities">some text5
<input type="checkbox" class="aminities" name="aminities">some text6
<input type="checkbox" class="aminities" name="aminities">some text7
<input type="checkbox" class="aminities" name="aminities">some text8
<input type="checkbox" class="aminities" name="aminities">some text9
</div>
<div id="floor_plans" class="floor_plans">
<div class="file_upload">
<label>Floor Plans</label>
<input type="file" name="upload_file1" id="upload_file1"/>
</div>
<div id="moreImageUpload"></div>
<div class="clear"></div>
<div id="moreImageUploadLink" style="display:none;margin-left: 10px;">
<a href="javascript:void(0);" id="attachMore">Attach another file</a>
</div>
</div>
<div id="image_gallery" class="image_gallery">
<label>Gallery:</label><input type="file" id="gallery" multiple="multiple" name="gallery"><input name="file" type="text" /><br>
</div>
<div id="project_specifications" class="project_features">
<label>Specifications:</label><textarea name="specifications" id="specifications" rows="5" cols="100"></textarea><br>
</div>
<div id="about_builder" class="about_builder">
<label>About_builder:</label><textarea name="about" id="about" rows="5" cols="100"></textarea><br>
</div>
<div id="form_submit">
<input type="button" name="submit" id="submit" value="Submit"/>
</div>
</fieldset>
</body>
推荐答案
Hello, please check, if this can help you :).
test.html
=========
Hello, please check, if this can help you :).
test.html
=========
<html>
<body>
<form action="test.php" method="post" enctype="multipart/form-data">
Upload multiple files:<br />
<input name="userfile[]" type="file" multiple="multiple" /><br />
<input type="submit" value="Upload" />
</form>
</body>
</html>
test.php
========
test.php
========
if (
_FILES[''userfile'']) {
_FILES[''userfile'']) {
file_ary = reArrayFiles(
file_ary = reArrayFiles(
这篇关于如何使用jQuery中的“浏览"按钮获取所选文件的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文