hello everyone,
i want to use following script to upload image files to remote server but only data is entered into tables but image files dont get upload to server. plz help.
<body bgcolor="#FFFFFF" text="#000000">
<?php
if ($submit)
{
$picnm = basename($picture_name);
$new_file_name = "www/webadmin/".$picnm;
if (!copy($picnm, $new_file_name))
echo "failed to copy file<br>\n";
return;
/* $the_path = "c:/webdev/www/testnrnd";
global $the_path, $the_file_name;
if (!@copy($picture, $the_path . "/" . $the_file_name))
{
printf("\n<b>Error ! Check the PATH to and the PERMISSIONS of the upload directory</b>");
echo 'error';
exit;
} */
$db = mysql_connect('localhost','root');
mysql_select_db('piyush', $db);
echo $picnm;
// exec("cp $picture /www/webadmin/$picnm");
$sql = "INSERT INTO cars VALUES ('$year','$make','$model','$price','$picnm')";
$result = mysql_query($sql,$db);
print mysql_error();
echo "year: $year<br>\n";
echo "make: $make<br>\n";
echo "model: $model<br>\n";
echo "price: $price<br>\n";
echo "temp file: $picture<br>\n";
echo "file name: $picture_name<br>\n";
echo "file size: $picture_size<br>\n";
echo "file type: $picture_type<br>\n";
echo "<br>\n";
echo "<img src=$picnm><br>\n";
}
?>
<form enctype="multipart/form-data" method="post" action="<?php echo $PHP_SELF ?>">
<p>year :
<input type="Text" name="year" size="25">
</p>
<p> make :
<input type="Text" name="make" size="25">
</p>
<p>model :
<input type="Text" name="model" size="25">
</p>
<p>price :
<input type="Text" name="price" size="25">
</p>
<p>picture :
<input type="File" name="picture" size="25">
</p>
<p>
<input type="submit" name="submit" value="Submit">
</p>
</form>
</body>
regards
mystic