Hi, I need help for my program.
I'm new With PHP but i have programming skills in VB so it's quit easy to understand this language, however. i got my self in some problems that i don't understand.
I made a form that should add a record to a database and upload a picture
to a databasepictures folder
the problems is it doesn't upload the selected file.
and $_files vars are empty
when I do a $_request first, The filename is stored like "C:\\folder\\test.jpg"
Please help
This is my form it as PHP in it to get de details from my database
<form name="form1" method="post" action="index.php">
<?
$user="myusername";
$password="mypassword";
$database="mydatabase";
$pro_id=$_POST['pro_id'];
$pro_type=$_POST['pro_type'];
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM pro_index";
mysql_query($query);
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
?>
Product type
<select name="type" size="1">
<?
while ($i < $num) {
$pro_id=mysql_result($result,$i,"pro_type_code");
$pro_type=mysql_result($result,$i,"Pro_type");
echo "<option>$pro_type</option>";
$i++;
}
mysql_close();
?>
</select>
<?
$pro_code_our++;
Echo "<br>Product number = BS$pro_code_our </p>";
?>
<br>
Product number from Factory
<input type="text" name="pronum">
<br>
Product name
<input type="text" name="proname">
<br>
Product details
<input type="text" name="prodetails" size="50">
<br>
Box size
<input type="text" name="probox">
<br>
Quantity
<input type="text" name="proquantity">
<br>
Picture
<INPUT NAME="uploaded" TYPE="File">
<br>
Factory number
<input type="text" name="facnum">
<br>
Buy Price
<input type="text" name="price">
<br>
<input type="submit" name="Submit" value="Add record">
<br>
</form>
this is my PHP code i try to use but doesn't work
<?
$target = "databasepictures/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
?>
This doesn't work and if i Print the $target it shows only "databasepictures/"
What is wrong or waht is missing