我不确定错误是什么,我无法读取错误,因为我被重定向到500错误并且无法判断错误,这是我的代码 -
html发送文件:
<form action="#" method="POST" class='form-horizontal form-validate' id="add-image" enctype='multipart/form-data'>
<div class="control-group">
<label for="select" class="control-label">Product</label>
<div class="controls">
<input type="hidden" name="type" id="type" class="input-xlarge" value="image">
<input type='hidden' name="issubmit" value="1">
<select name="product" id="product" class='input-xxlarge'>
<?php
$testsql = "SELECT product_id,UPPER(concat(product_code,' - ',product_name,' - ',category_name,' - ', subcat_name)) as product_name FROM category ca,product pro,subcategory su where su.subcat_id=pro.subcat_id and su.category_id=ca.category_id ORDER BY product_id ";
$testresult = mysql_query($testsql);
while ($row = mysql_fetch_array($testresult))
{
echo "<option value=\"". $row['product_id']."\">". $row['product_name']. "</option>";
}
?>
</select>
</div>
</div>
<div class="control-group">
<label for="textfield" class="control-label"></label>
<div class="controls">
<div class="check-demo-col" style="width:175px;">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 100px; height: 100px;"><img src="../upload/sample.jpg" /></div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 100px; max-height: 100px; line-height: 2px;"></div>
<div>
<span class="btn btn-file"><span class="fileupload-new">Select main-view</span><span class="fileupload-exists">Change</span><input type="file" name='imagefile[]' /></span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
</div>
</div>
</div>
<div class="check-demo-col" style="width:175px;">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 100px; height: 100px;"><img src="../upload/sample.jpg" /></div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 100px; max-height: 100px; line-height: 20px;"></div>
<div>
<span class="btn btn-file"><span class="fileupload-new">Select left-view</span><span class="fileupload-exists">Change</span><input type="file" name='imagefile[]' /></span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
</div>
</div>
</div>
<div class="check-demo-col" style="width:175px;">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 100px; height: 100px;"><img src="../upload/sample.jpg" /></div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 100px; max-height: 100px; line-height: 20px;"></div>
<div>
<span class="btn btn-file"><span class="fileupload-new">Select right-view</span><span class="fileupload-exists">Change</span><input type="file" name='imagefile[]' /></span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
</div>
</div>
</div>
<div class="check-demo-col" style="width:175px;">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 100px; height: 100px;"><img src="../upload/sample.jpg" /></div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 100px; max-height: 100px; line-height: 20px;"></div>
<div>
<span class="btn btn-file"><span class="fileupload-new">Select top-view</span><span class="fileupload-exists">Change</span><input type="file" name='imagefile[]' /></span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
</div>
</div>
</div>
<div class="check-demo-col" style="width:175px;">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 100px; height: 100px;"><img src="../upload/sample.jpg" /></div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 100px; max-height: 100px; line-height: 20px;"></div>
<div>
<span class="btn btn-file"><span class="fileupload-new">Select bottom-view</span><span class="fileupload-exists">Change</span><input type="file" name='imagefile[]' /></span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
</div>
</div>
</div>
</div>
</div>
<div class="control-group">
<label for="select" class="control-label">Status</label>
<div class="controls">
<select name="status" id="status" class='input-large'>
<option value="active">Active</option>
<option value="disabled">Disabled</option>
<option value="inactive">Inactive</option>
</select>
</div>
</div>
<div class="form-actions">
<input type="submit" class="btn btn-primary" value="Submit" name="submit">
<button type="button" class="btn">Cancel</button>
</div>
</form>
,我的php是:
if(isset($_REQUEST['submit']))
{
if(isset($_REQUEST['product']))
{
$product=$_REQUEST['product'];
// echo $product;
}
if(isset($_REQUEST['status']))
{
$status=$_REQUEST['status'];
// echo $status;
}
$target = "../upload/";
$count=0;
foreach ($_FILES['imagefile']['name'] as $filename)
{
$temp=$target;
$tmp=$_FILES['imagefile']['tmp_name'][$count];
$extension = pathinfo($filename, PATHINFO_EXTENSION);
// echo $extension;
$temp=$temp.basename($product.'_'.($count + 1).'.'.$extension);
move_uploaded_file($tmp,$temp);
// echo $temp;
//This gets all the other information from the form
$image=($_FILES['imagefile']['name']);
if($image[$count])
{
// $insert=mysql_query("INSERT INTO image VALUES (DEFAULT,'$product','$temp','$image[$count]','$status')") ;
}
$count=$count + 1;
$temp='';
$tmp='';
}
}
我收到以下错误:
服务器遇到内部错误或配置错误,无法完成您的请求。请与服务器管理员联系,以告知错误发生的时间以及可能导致错误的任何操作。服务器错误日志中可能提供了有关此错误的更多信息。
我无法读取错误日志,error_reporting(E_ALL); ini_set('display_errors', 'on');
无效。
只是为了检查,我评论/删除了move_uploaded_file($tmp,$temp);
,发现格式或代码没有错误。 move_uploaded_files()
正在解决问题,我尝试添加
php_value upload_max_filesize 8M
php_value post_max_size 8M
php_value max_execution_time 200
php_value max_input_time 200
到.htaccess
并找不到任何帮助。文件大小无论如何都不到1MB,所以这根本不是问题,我想。
答案 0 :(得分:0)
isset()函数只能返回TRUE或FALSE,但是您要检查它是否具有POST值。只需在if语句中使用isset($_POST['submit'])
,就可以检查它是否设置为TRUE。要检查它是否为假,您可以将其更改为!isset($_POST['submit'])
。
错误日志将更准确地说明 500错误消息的原因。我不认为if语句中的错误会导致 500错误。
如果您无法检查错误日志,请在PHP文件的顶部添加
error_reporting(E_ALL);
ini_set('display_errors', 'on');