I'm trying to get a file upload working for a CMS.
However, it doesn't work upload. I'm getting some errors... perhaps someone can spot the error.
It appears to me that the $cityid variable is not being passed along.
This is the trimmed INSERT statement:
Code: Select all
if($_POST['bpress']=="add")
{
$sql = "INSERT INTO city (
City_Image,
City_Name,
VALUES (
'none',
'".$_POST["name"]."')";This is the additional upload script that works off of the information above:
Code: Select all
$sql = "SELECT
City_ID,
City_Name,
FROM city WHERE
City_Name='".str_replace("'","'",$_POST["name"])."'";
$cityresults = mysql_fetch_array($result);
$cityid = $cityresults["City_ID"];
//setcookie ("City_ID", $cityid);
mkdir($_SERVER['DOCUMENT_ROOT']."httpdocs/Imi/City_Img/".$cityid);
$picname="noimage.jpg";
$City_Image = "City_Image";
$counter=1;
foreach( $HTTP_POST_FILES as $aFile )
{
if ($aFile['type'] == "image/gif" || $aFile['type'] == "image/jpeg" || $aFile['type']=="image/pjpeg")
{
copy ($aFile['tmp_name'], $_SERVER['DOCUMENT_ROOT']."/City_Img/".$cityid."/".$aFile['name'])
or die ("Could not copy");
echo "";
// $picname=$aFile['name'];
}
$picname=$aFile['name'];
$City_Image = "City_Image".$counter;
$sql = "UPDATE city SET ".$City_Image." = '".$picname."' WHERE City_ID=".$cityid;
$counter++;
}Code: Select all
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM city WHERE City_Name='Montreal'' at line 4error on selectI notice the slashes are reversed to what is being output...
Linux/Windows thing?
Code: Select all
Warning: mkdir(/httpdocs/Imi/City_Img/): No such file or directoryCode: Select all
Warning: copy(/httpdocs/Imi/City_Img//montreal.jpg): failed to open stream: No such file or directory Could not copy