页面在图片上传后没有重定向,它在localhost中没有任何问题。
<?php
if(! empty($_FILES["img"]["name"]))
{
include("config.php");
$temp=pathinfo($_FILES["img"]["name"]);
$ext=strtolower( $temp["extension"]);
$file_nm=time()."_chiragexport.".$ext;
move_uploaded_file($_FILES["img"]["tmp_name"],"../uploads/".$file_nm);
//convert size
include('includes/resize.php');
$image = new SimpleImage();
$image->load('../uploads/'.$file_nm);
$image->resize(250,250);
$image->save('../uploads/small/'.$file_nm);
//product code---------------------
$code1=rand(1000,9999);
$a="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$code=substr($a,rand(0,51),2).$code1;
$q="insert into sub_products(sub_main_p_id,sub_p_nm,sub_p_img,sub_p_small_img,sub_p_code)
values
('".$_POST['main_p_id']."', '".$_POST['sub_p_nm']."', 'uploads/".$file_nm."' ,'uploads/small/".$file_nm."','".$code."' )";
mysql_query($q);
header("location: sub_products.php?id=".$_POST['main_p_id']."");
}
else
{
header("location: sub_products.php?id=".$_POST['main_p_id']."");
exit;
}
?>
答案 0 :(得分:0)
你要包含几个文件。可能其中一个文件在顶部或底部有一个空行,导致服务器已经发送了一些数据。这样,header()不再起作用了
答案 1 :(得分:-1)
不要写这个非常复杂的引号问题,而是尝试最小化引号
header("location: sub_products.php?id=".$_POST['main_p_id']."");
因此请使用此代替上述
$val=$_POST['main_p_id'];
header("Location:sub_products.php?id=$val");