我想上传一张有图片的表格。我能得到品牌名称等数据。这是我的代码片段。我不知道图像的名称和类型。此代码中需要做哪些更改?正在获取错误。
move_uploaded_file():无法将“/tmp/phpRBnjTS”移动到
'/var/www/html/download.jpg'输入
/var/www/html/rtc/view/setup_config.php,第156行,参考:
http://192.168.50.123/rtc/view/setup_config.php
<form name="formcfg" id="formcfg" action="" method="post">
<input type="hidden" name="mode" id="mode" value="insert" />
<div id="dashboard">
<h2>Brand Name</h2>
<div>
<table width="100%">
<tr>
<td width="15%">Brand Name*</td>
<td width="92%">
<input type="text" name="context" id="context" class="input required" placeholder="Brand /directory Name" title="Brand /directory Name"/>
</td>
</tr>
<tr>
<td width="15%">Brand Logo</td>
<td id="tmp" width="92%">
<input type ="file" name ="image" style="width:180px;height:20px"><span id='val'></span>
<input type="hidden" name="MAX_FILE_SIZE" value="2097152" />
</td>
</tr>
</table>
</div>
<span class="clear" style="float:left; margin-top:5px;margin-bottom:5px; margin-left:60px;">
<input type="submit" name="submit" required class="btn" value="submit"></span>
</form>
<?php
if(isset($_POST['submit']) || isset($_FILES['image']['name']))
{
$BrandName=$_POST['context'];
$filename = $_FILES['image']['name'];
$type=$_FILES['image']['type'];
$path= '/var/www/html/';
$filedata = file_get_contents($fpath);
error_log("===file is $filename===");
if($filename!="")
{
move_uploaded_file($_FILES['image']['tmp_name'],$path.$filename);
}
}
?>
最佳答案
您需要将此添加到表单标记中
<form name="formcfg" id="formcfg" action="" method="post" enctype="multipart/form-data">
图像需要表单类型为编码多部分。