Hello everyone,
I've gotten the script I've been working on to work fairly well, thanks to the debugging help of ClarkF1.
I've now run into another problem just when I thought I had it.
I have 6 upload forms on one page, and when you hit any of the 6 submits, a picID gets sent to uploader.php which determines which submit you used.
It then renames the picture accordingly.
Example: I hit submit on upload 5, the image uploads and gets renamed to 5_img.jpg
The problem I'm having is that, when I run through the form for the first time, starting from upload 1 to 6, they all upload fine, and are named correctly.
However, when I go back and change any of the uploads, ( say I upload a new image into upload3), it changes 6_img.jpg with the image instead of 3_image.jpg.
Whatever else I try to change, only 6_img.jpg changes.
Correct Examples: upload1 --> 1_img.jpg
upload2 --> 2_img.jpg
upload3 --> 3_img.jpg
etc...
Incorrect Examples: upload1 --> 6_img.jpg
upload2 --> 6_img.jpg
etc...
Here is the uploader.php
<?
// Connect to DATABASE
$conn = mysql_connect("localhost","******","******");
// Connect to Table and stores connection as variable: conn
$db = mysql_select_db("******_academicPrograms", $conn);;
// Queries the user input data with the database data
$result = MYSQL_QUERY("SELECT * from academicPrograms")
or die ("Data not found");
// Gets boolean value of whether the query worked
$worked = mysql_fetch_array($result);
// Gets all values from table and stores them as variables
$pictureID = $worked[pictureID];
// Connects to Database for uploading image through FTP
$ftpconn = ftp_connect("******") or die("Could not connect");
ftp_login($ftpconn,"******","******");
// The Directory the file will be placed
$target_path = "Images/academicPrograms/";
// I think the problem is here
if($pictureID = '1'){$uniqueName = "1_img.jpg";}
if($pictureID = '2'){$uniqueName = "2_img.jpg";}
if($pictureID = '3'){$uniqueName = "3_img.jpg";}
if($pictureID = '4'){$uniqueName = "4_img.jpg";}
if($pictureID = '5'){$uniqueName = "5_img.jpg";}
if($pictureID = '6'){$uniqueName = "6_img.jpg";}
//Assigns a the path and the name together
$uniqueID= $target_path.$uniqueName;
//Moves to temp file to the targetpath
$_FILES['uploadedfile']['tmp_name'];
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uniqueID)) {
echo "<script>window.location=\"new.php?picID=".$_POST['picID']."\"</script>"; }
else{
echo "There was an error uploading the file, please try again!";
}
?>
Like I said, everything works, it's just the images overwrite the wrong ones.
Thanks for any help