gpt4 book ai didi

上传两个文件时上传php文件

转载 作者:行者123 更新时间:2023-11-30 23:14:08 25 4
gpt4 key购买 nike

在 php 中我有一个这样的文件上传脚本

<form id="formID" method="post" action="'.$_SERVER['REQUEST_URI'].'" enctype="multipart/form-data">
<div>
<label>'.$this->l('Upload Your Custom Pin').'</label>
<input type="file" name="file" id="file" />
</div>
<div>
<label>'.$this->l('Upload Your Store Image').'</label>
<input type="file" name="store_image" id="store_image" />
</div>
<input type="submit" name="submit" value="submit" />
</form>



$image_name = time().$_FILES['file']['name'];
$store_image_name = time().$_FILES['store_image']['name'];

if(isset($_POST['submit'])) {
mysql_query('INSERT INTO `'._DB_PREFIX_.'databasename` (`id`, `custom_pin_name`,`store_image_name`) values ('', $custom_pin,$store_img_name) or die(mysql_error());
if(move_uploaded_file($_FILES['file']['tmp_name'], $tmpName.$image_name) && ($_FILES['store_image']['tmp_name'], $tmpName.$store_image) ) {
$this->_html .=$this->displayConfirmation($this->l('Settings updated successfully'));
} else {
$errors .= $this->displayError($this->l('You Have Some Errors'));
}
}

在这里您可以看到我正在上传两个文件并将它们移动到目录中。但是当我这样做来移动上传文件时,它会显示类似

的错误

解析错误:第 18 行(我使用 move_uploaded_file 的地方)出现语法错误、意外的“,”。

但是当我像这样只使用一个文件时

 if(isset($_POST['submit'])) {
mysql_query('INSERT INTO `'._DB_PREFIX_.'databasename` (`id`, `custom_pin_name`,`store_image_name`) values ('', $custom_pin,$store_img_name) or die(mysql_error());
if(move_uploaded_file($_FILES['file']['tmp_name'], $tmpName.$image_name) ) {
$this->_html .=$this->displayConfirmation($this->l('Settings updated successfully'));
} else {
$errors .= $this->displayError($this->l('You Have Some Errors'));
}
}

一切顺利。那么有人可以告诉我如何解决这个问题吗?

最佳答案

您在 && 之后缺少 move_uploaded_file。线路

if(move_uploaded_file($_FILES['file']['tmp_name'], $tmpName.$image_name) && ($_FILES['store_image']['tmp_name'], $tmpName.$store_image) ) {

应该是

if(move_uploaded_file($_FILES['file']['tmp_name'], $tmpName.$image_name) && move_uploaded_file($_FILES['store_image']['tmp_name'], $tmpName.$store_image_name) ) {

您还有 $store_image,它应该是 $store_image_name

关于上传两个文件时上传php文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18658620/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com