Hi All, This is my first post and I am not super good at coding with php so if this seems a bit "simple or "stupid" my apologies.
I have this code (which works and will upload a photo and add info to the database) that I had finally gotten to work well. I edited it to upload a photo, a title and paypal button code. I have tried everything I can think of to make this code work and it's just not. It gives errors like this.
Warning: move_uploaded_file(uploads/Decal.jpg): failed to open stream: No such file or directory in /home/website/public_html/paypal/paypal-add.php on line 15
Warning: move_uploaded_file(): Unable to move '/tmp/phpjVp2F8' to 'uploads/Decal.jpg' in /home/website/public_html/paypal/paypal-add.php on line 15
I am not sure why this exact code works to upload a file in another section of the site, but the code below always bombs. I did get it to work once, when I placed a php script at the top to display all the php settings of the web server. (No clue why) I am hoping someone out there will see that I have done wrong here and why this won't function. There is an uploads folder in the same folder as this code. The setting on the database are accurate to the variable in the code. The settings are also accurate. Any thoughts would be appreciated.
The code.
<?php
include 'settings.php';
// Initialize DBase
$con = mysqli_connect("$dbHost","$dbUsername","$dbPassword")or die('Could not connect: ' . mysqli_connect_error());
mysqli_select_db($con,"$dbName")or die("Cannot select the database.");
// Set Variables
$fileName = $_FILES['fileName']['name']; $statusMsg = '';
$product_name = $_POST['product_name'];
$paypal_code = $_POST['paypal_code'];
$PathName = "uploads/";
// Copy Image File To Directory And Write the information to the database
$Success = move_uploaded_file($_FILES['fileName']
['tmp_name'],$PathName.$fileName);
if($Success)
{
$sql="INSERT INTO $table (fileName, product_name, paypal_code) VALUES ('$fileName','$product_name','$paypal_code')";
if(!mysqli_query($con,$sql)) {$statusMsg = 'There was an error saving the sample.';}
else {header("Location: paypal-list.php");}
}
else {$statusMsg = 'There was an error saving the sample.';}
mysqli_close($con); echo $statusMsg; exit;
?>
Thanks