I have an odd situation here that I cant seem to figure out.
I have this form in which I input data that get inserted in the the DB and uploads an image. IF the image uploads, then the DB is updated. Then IF the info is entered and the image is uploaded it asks for the to be uploaded.
I get this error:
Warning: copy(C:\Documents and Settings\Owner\Desktop\Spechal.com\Site Backups\mainsite\images\adformatter.gif): failed to open stream: No such file or directory in /home2/XXXXX/public_html/secure/addtool.php on line 75
Error :: Did not upload source file.
Using this code the first file copy passes but the second dies. Anyone know why? THANKS!!!
<?php
if(isset($_POST['submit']) && (!isset($_POST['upload']))){
include('../connect.inc.php');
if(!$title || !$highlights || !$details || !$price || !$price_block || !$fav) { $msg = "Error :: Please fill out all feilds."; $err = TRUE; }
if(filesize($file)>100000){ $msg = "Error :: Image size is greater than 100000 bytes."; $err = TRUE; }
if(!copy($file, "/home/XXXXX/public_html/images/".$file_name)) { $msg = "Error :: Could not copy image to destination."; $err = TRUE; }
if($err == TRUE){ echo "<p class='list' align='center'>".$msg."</p>"; exit();
} else {
$sql = mysql_query("INSERT INTO paidtools (title, image, highlights, details, price, price_block, fav) VALUES ('$title', '$file_name', '$highlights', '$details', '$price', '$price_block', '$fav')") or die(mysql_error());
if($sql) { echo "<p class='list' align='center'>Information entered into the database. Please upload the product file now.</p>";
echo "<form action='$PHP_SELF' method='POST'><input type='file' class='button' name='file'><br><input type='submit' name='upload' value=' Submit ' class='button'></form>"; }
else { echo "<p class='list' align='center'>Error :: Something went wrong with the query.</p>"; }
}//end
} elseif(isset($_POST['upload'])){
if(copy($file, "/home/XXXXX/public_html/XXXXX/".$file_name)){ echo "<p class='list' align='center'>".$file_name." was uploaded.</p>"; }
else { echo "<p class='list' align='center'>Error :: Did not upload source file.</p>"; } // end upload
} else {
?>
NOTE:: I just noticed how my scripts are set to go to /home/username/ but the error says /home2/username/
Why would the first one pass (it it really did, the file is there) and the second fail?