php - upload a file form - doesn't recognize the $_FILES variable -
i've got following form:
<form method="post" action="index.php"> product name: <input type="text" name="product_name" value="<?php echo $product_name;?>"/> <br /> <br /> product details <textarea rows = "6" cols = "30" name="product_details" > <?php echo $product_details;?></textarea> <br /> <br /> product price <input type="text" name = "product_price" value="<?php echo $product_price;?>"/> <br /> <br /> cn: <input type="text" name = "product_cn" value="<?php echo $product_cn;?>"/> <br /> <br /> image <input type="file" name="filefield" /> <br /> <br /> <input type="submit" name="submit" value="register product" /> </form>
my problem is, whenever try process image using code:
move_uploaded_file($_files['filefield']['tmp_name'], "../product_images/$newname");
i following error:
notice: undefined index: filefield
why that?
thanks in advance!
you have add enctype='multipart/form-data'
form
quote topic this
when make post request, have encode data forms body of request in way.
html forms provide 2 methods of encoding. default application/x-www-form-urlencoded, more or less same query string on end of url. other, multipart/form-data, more complicated encoding 1 allows entire files included in data.
Comments
Post a Comment