I have a simple script to accept an image from a user, then copy it to a folder in my web directory. However the picture does not get copied, nor is the picture name added to the database.
the script is:
<?php
if ($submit)
{
$db = mysql_connect("localhost", "user", "password") or die ("Could not connect to server");
$conn = mysql_select_db("realty", $db) or die ("Could not connect to database");
$sql = "INSERT INTO realtor (agent, agent_picture_name, description, house_picture_name) ";
$sql .= "VALUES ('$agent', '$agent_picture_name', '$description', '$picture_name')";
MYSQL_QUERY($sql) or die ("Could not run query");
MYSQL_CLOSE();
exec ("cp $picture /var/www/html/webprogs/realty/images/$picture_name");
exec("cp $agent_picture /var/www/html/webprogs/realty/agentimages/$agent_picture_name");
include("houseDisplay.php");
echo "<center><a href=\"$PHP_SELF\">Enter another</a></center>";
}
else
{
echo "Not in!";
echo "<form enctype=\"multipart/form-data\" method=\"get\" action=\"$PHP_SELF\">";
echo "Agent:<br>";
echo "<input type=\"text\" name=\"agent\" size=\"25\"><br>";
echo "Agent picture:<br>";
echo "<input type=\"file\" name=\"agent_picture\" size=\"25\"><br>";
echo "Describe the house for sale. (include the address, price, and any pertinent info):<br>";
echo "<textarea rows=\"10\" cols=\"60\" name=\"description\"></textarea><br>";
echo "Picture of House:<br>";
echo "<input type=\"File\" name=\"picture\" size=\"25\"><br>";
echo "<input type=\"Submit\" name=\"submit\" value=\"Upload\"><br>";
}
?>
I was able to get this same script to work on an IIS server using the copy command instead of exec(cp...)
What am i doing wrong???
Is there an issue with directory permissions? Or my php.ini configuration, I have file uploads set to on.
I am at a loss...