如何在引导程序中获取下一页的图像值[重复]
Posted
技术标签:
【中文标题】如何在引导程序中获取下一页的图像值[重复]【英文标题】:How to get the image value in bootstrap for next page [duplicate] 【发布时间】:2016-02-28 05:26:26 【问题描述】:<form action="original_photo_upload.php" method="POST" id="form" name="form" class="form-horizontal" style="margin-top: 20px;">
<div class="form-group">
<label class="control-label col-xs-4">File Upload</label>
<div class="col-md-8">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="input-append">
<div class="uneditable-input">
<i class="fa fa-file fileupload-exists"></i>
<span class="fileupload-preview"></span>
</div>
<span class="btn btn-default btn-file">
<span class="fileupload-exists">Change</span>
<span class="fileupload-new">Select file</span>
<input type="file">
</span>
<a href="#" class="btn btn-default fileupload-exists" data-dismiss="fileupload">Remove</a>
</div>
</div>
</div>
</div>
</form>
我想在 Db 中插入图像值并将照片移动到一个文件夹中,我知道正常形式但引导我很困惑,如何在 original_photo_upload.php 中获取图像值
【问题讨论】:
【参考方案1】:<form action="original_photo_upload.php" enctype='multipart/form-data' method="POST" id="form" name="form" class="form-horizontal" style="margin-top: 20px;">
<div class="form-group">
<label class="control-label col-xs-4">File Upload</label>
<div class="col-md-8">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="input-append">
<div class="uneditable-input">
<i class="fa fa-file fileupload-exists"></i>
<span class="fileupload-preview"></span>
</div>
<span class="btn btn-default btn-file">
<span class="fileupload-exists">Change</span>
<span class="fileupload-new">Select file</span>
<input type="file" name="image">
</span>
<input type="button" class="btn btn-default fileupload-exists" data-dismiss="fileupload" value="submit">
<input type="button" class="btn btn-default fileupload-exists" data-dismiss="fileupload" value="remove">
</div>
</div>
</div>
</div>
</form>
和php查询
<?php if(isset($_POST['submit']))
$ImageName = $_FILES['image']['name'];
$path = 'images/';
$location = $path . $_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], $location);
?>
还有更详细的搜索图片上传功能。
【讨论】:
【参考方案2】:将您的表单更改为:
<form form action="original_photo_upload.php" method="post" enctype="multipart/form-data" class="form-horizontal" style="margin-top: 20px;">
还将您的输入更改为:
<input name="file" type="file">
您的表单,需要提交才能发送数据。所以,添加:
<input type="submit" value="ok">
在他的文件中: original_photo_upload.php 做了一个条件。比如:
<?php
if (isset($_FILES['file']))
var_dump($_FILES);
仅用于测试。
更新 要执行上传:
move_uploaded_file($_FILES['file']['tmp_name'], 'upload/' . $_FILES['file']['name']);
【讨论】:
var_dump($_FILES);//array(1) ["file"]=> array(5) ["name"]=> string(12) "DSC05019.JPG" [ "type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(24) "C:\xampp\tmp\phpFBD5.tmp" ["error"]=> int(0) [ "size"]=> int(4165988) 如何只获取文件名 我明白了,谢谢... 要获取文件名,请使用:echo $_FILES['file']['name'];
但是,如果要执行上传,则需要 tmp_name。我更新了我的答案。看!以上是关于如何在引导程序中获取下一页的图像值[重复]的主要内容,如果未能解决你的问题,请参考以下文章