-1

我在上传文件时遇到问题,我正在使用此代码......并收到此错误,

我的文件夹名称是服装图像

 <?php
    $pid          = mysql_insert_id();
    $folder       = $_post['catagory'];
    //insert images into folder
    $product_name = "$pid.jpg";
    move_uploaded_file($_FILES['productImage']['tmp_name'], "$folder._images" / $product_name);
    echo "<h1>Your product successfully added <br /> Plese wait....</h1>";
    header("refresh:3; url='inventory.php'");
    exit();
    ?>
    <form method='post' action='index.php'>
    <input type="file" name="productImage" />
<input type="text" name="catagory" />
    </form>
4

2 回答 2

2

纠正了几个错误,这是您的代码:

<?php
$pid          = mysql_insert_id();
$folder       = $_POST['category']; // assuming you had category other wise, no correction
//insert images into folder
$product_name = "$pid.jpg";
move_uploaded_file($_FILES['productImage']['tmp_name'], "$table._images/ $product_name"); // string concat mistake
echo "<h1>Your product successfully added <br /> Please wait....</h1>";
echo "<meta http-equiv='refresh' content='3; inventory.php' />";// use meta tag to redirect instead of header which will give you headers already sent error
// exit(); // if not commented out, the below form will never be shown!
?>
<form method='post' action='index.php'>
<input type="file" name="productImage" />
</form>

如果您开始使用 PHP,并且需要帮助,我强烈建议您在编码时使用 IDE。

于 2012-10-23T11:11:50.807 回答
1

你写了'刷新',正确的是'刷新'。

于 2012-10-23T11:06:56.297 回答