am getting following error everytime try upload file .
"warning: file upload error - unable create temporary file in unknown on line 0"
here html form,
<form action="./inventory_list.php" enctype="multipart/form-data" name="myform" id="myform" method="post"> <table width="625" border="1" cellpadding="5"> <tr> <td width="84">product name</td> <td width="399"><input type="text" name="product_name" id="product_name"></td> </tr> <tr> <td>product price</td> <td><label for="textfield2">rs:</label> <input type="text" name="price" id="price"></td> </tr> <tr> <td>category</td> <td><select name="category" id="category"> <option value="" selected="selected"></option> <option value="bedroom ">bedroom </option> <option value="living">living room</option> <option value="dining">dining</option> </select></td> </tr> <tr> <td>sub - category</td> <td><select name="subcategory" id="subcategory"> <option value="" selected="selected"></option> <option value="dinet">dining tables</option> <option value="shoe">shoe racks</option> <option value="wardrobe">wardrobes</option> <option value="sofa">sofa</option> </select></td> </tr> <tr> <td>product details</td> <td><textarea name="details" cols="50" rows="10" id="details"></textarea></td> </tr> <tr> <td>product image</td> <td><label> <input type="file" name="filefield" id="filefield"/> </label></td> </tr> <tr> <td> </td> <td><input type="submit" name="button" id="button" value="add item now"></td> </tr> </table> </br> </form>
here php code ,
if(isset($_post["product_name"])) { $product_name = mysql_real_escape_string($_post["product_name"]); $price= mysql_real_escape_string($_post["price"]); $category= mysql_real_escape_string($_post["category"]); $subcategory= mysql_real_escape_string($_post["subcategory"]); $details= mysql_real_escape_string($_post["details"]); //see if duplicate product exists $sql = mysql_query("select id products product_name='$product_name' limit 1"); $product_match = mysql_num_rows($sql); //count output if($product_match>0) { echo "the product name exists"; exit(); } $sql= mysql_query("insert `mystore`.`products` (`product_name`, `price`, `details`, `category`, `subcategory`, `date_added`) values ( '$product_name', '$price', '$details', '$category', '$subcategory', now());")or die(mysql_error()); $pid = mysql_insert_id(); $newname = "$pid.jpg"; move_uploaded_file($_files['filefield']['tmp_name'],'../inventory_images/$newname'); }
am trying upload on localhost , test server:xampp , os : mac 10.8
am stuck on long time , tried lot of things nothing working .
in terminal type :
chmod -r 777 /your/upload/folder
you can know folder php uploads files executing code :
$tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(); die($tmp_dir);
in case /var/...
when sett 777 permission no error.
edit
setting 777 /var
dangerous have set folder php uploads file (which can buy code above).