简单代码正常工作: 形式:
<form name="newad" method="post" enctype="multipart/form-data" action="betterplace.php">
<input type="file" name="delhi" required="required" value="delhi" onchange="javascript:this.form.submit();">
</form>
Action:
$mumbai=$_FILES['image']['tmp_name'];
$sql = " SELECT xyz FROM `dataperiod` WHERE cities LIKE '$mumbai' ";
if(!$result = $conn->query($sql)){
die('There was an error running the query [' . $conn->error . ']');
}
/do the stuff
但是为了制作空房产,我为此分配了一套isset代码:
<?php
if(isset($_POST) && !empty($_POST)) {
$mumbai=$_FILES['image']['tmp_name'];
$sql = " SELECT xyz FROM `dataperiod` WHERE cities LIKE '$mumbai' ";
if(!$result = $conn->query($sql)){
die('There was an error running the query [' . $conn->error . ']');
}
/do the stuff
}
else{
header('location: home.php'); exit();
}
?>
但没有任何表现或工作。我认为问题不在于发布元素。请帮助。
答案 0 :(得分:0)
是否primaryColorLayout .setBackgroundColor(Color.parseColor("#000000"));
触发并重定向到onchange="javascript:this.form.submit();"
?
无论如何,betterplace.php
错误,isset($_POST)
始终设置,但可以为空,因此,由于文件始终通过$_POST
传输,因此您需要就像这样:
POST/PUT
仔细看if (isset($_FILES['delphi'])) {
...
}
。您的文件输入名为$_FILES['delphi']
,而不是delphi
(正如您在image
中假设的那样):
mumbai=$_FILES['image']['tmp_name'];
所以,最后:
<input type="file" name="delhi" ... >
或者:
<?php
if (isset($_FILES['delphi']) && is_uploaded_file($_FILES['delphi']['tmp_name'])) {
$mumbai = $_FILES['delphi']['tmp_name'];
...
}