kenwvs
08-21-2006, 01:16 PM
I have a form that has about 15 fields in it, and it is an all in one script that uploads all the information to the database, from within itself.
I have just added an image upload script to it that requires a second script that uploads the images to a folder on the server.
I am trying to understand how to make this all work. I have changed the form action to direct it to the second script. Would I then need to move the query that uploads my form fields to this second script as well, or will it run from the first (actual form) script, then go to the second script and move the images?
I also need to have the names of the images load into a column in the DB table, but not sure how to setup the query for this.
Here is the information, but not sure how to write it in the query itself....
This is the query that collects all the data from the form (the last 4 items are a start for the images)
<?php
if (!isset($_POST['Submit'])){
?>
All the current form fields are in between these two codes (set up and working)
} else
{
$Work = $_POST["Work"];
$Sched = $_POST["Sched"];
$Name = $_POST["Tech"];
$Site = $_POST["Site"];
$Serial = $_POST["Serial"];
$Hours = $_POST["Hours"];
$Starts = $_POST["Starts"];
$Issue = $_POST["Issue"];
$Severity = $_POST["Severe"];
$Resolution = $_POST["Resolve"];
$Assistance = $_POST["Assist"];
$PartsA = $_POST["PartsA"];
$PartsB = $_POST["PartsB"];
$PartsC = $_POST["PartsC"];
$PartsD = $_POST["PartsD"];
$PartsE = $_POST["PartsE"];
$PartsF = $_POST["PartsF"];
$PartsG = $_POST["PartsG"];
$Safety = $_POST["Safe"];
$Purchase = $_POST["Purchase"];
$Comment = $_POST["Comment"];
$Remarks = $POST_["Remarks"];
$Uploads1 = $POST_["uploadfile"];
$Uploads2 = $POST_["uploadfile"];
$Uploads3 = $POST_["uploadfile"];
$Uploads4 = $POST_["uploadfile"];
mysql_query ("Insert into `workorder`(Work, Sched, Name, Site, Serial, Hours,
Starts, Issue, Severity, Resolution, Assistance, PartsA, PartsB, PartsC, PartsD,
PartsE, PartsF, PartsG, Safety, Uploads1, Uploads2, Uploads3, Uploads4) VALUES
('$Work', '$Sched', '$Name', '$Site', '$Serial', '$Hours', '$Starts', '$Issue',
'$Severity', '$Resolution', '$Assistance', '$PartsA','$PartsB', '$PartsC',
'$PartsD', '$PartsE','$PartsF', '$PartsG', '$Safety', '$Uploads1','$Uploads2',
'$Uploads3', $Uploads4 )")or die(mysql_error());
echo "This Work Order has been Updated Successfully";
}
This is the part of the image script that names the images... and not sure how to get this into the query to go to the db. This information is in the second script. There are a maximum of 4 images that can be uploaded.
if ($_FILES['upload']['error'][$i] == 0)
{
$uploaddir = '/public_html/benjamin/GEUploads';
$uploadfile = $uploaddir . basename($_FILES['upload']['name'][$i]);
move_uploaded_file($_FILES['upload']['tmp_name'][$i], $uploadfile);
if (!move_uploaded_file($_FILES['upload']['tmp_name'][$i], $uploadfile))
{
die("<br><br><span>File could not be uploaded.</span>");
}
elseif (!is_uploaded_file ($uploadfile))
{
die("<br><br><span>Your file was not uploaded successfully.</span>");
}
}
I have just added an image upload script to it that requires a second script that uploads the images to a folder on the server.
I am trying to understand how to make this all work. I have changed the form action to direct it to the second script. Would I then need to move the query that uploads my form fields to this second script as well, or will it run from the first (actual form) script, then go to the second script and move the images?
I also need to have the names of the images load into a column in the DB table, but not sure how to setup the query for this.
Here is the information, but not sure how to write it in the query itself....
This is the query that collects all the data from the form (the last 4 items are a start for the images)
<?php
if (!isset($_POST['Submit'])){
?>
All the current form fields are in between these two codes (set up and working)
} else
{
$Work = $_POST["Work"];
$Sched = $_POST["Sched"];
$Name = $_POST["Tech"];
$Site = $_POST["Site"];
$Serial = $_POST["Serial"];
$Hours = $_POST["Hours"];
$Starts = $_POST["Starts"];
$Issue = $_POST["Issue"];
$Severity = $_POST["Severe"];
$Resolution = $_POST["Resolve"];
$Assistance = $_POST["Assist"];
$PartsA = $_POST["PartsA"];
$PartsB = $_POST["PartsB"];
$PartsC = $_POST["PartsC"];
$PartsD = $_POST["PartsD"];
$PartsE = $_POST["PartsE"];
$PartsF = $_POST["PartsF"];
$PartsG = $_POST["PartsG"];
$Safety = $_POST["Safe"];
$Purchase = $_POST["Purchase"];
$Comment = $_POST["Comment"];
$Remarks = $POST_["Remarks"];
$Uploads1 = $POST_["uploadfile"];
$Uploads2 = $POST_["uploadfile"];
$Uploads3 = $POST_["uploadfile"];
$Uploads4 = $POST_["uploadfile"];
mysql_query ("Insert into `workorder`(Work, Sched, Name, Site, Serial, Hours,
Starts, Issue, Severity, Resolution, Assistance, PartsA, PartsB, PartsC, PartsD,
PartsE, PartsF, PartsG, Safety, Uploads1, Uploads2, Uploads3, Uploads4) VALUES
('$Work', '$Sched', '$Name', '$Site', '$Serial', '$Hours', '$Starts', '$Issue',
'$Severity', '$Resolution', '$Assistance', '$PartsA','$PartsB', '$PartsC',
'$PartsD', '$PartsE','$PartsF', '$PartsG', '$Safety', '$Uploads1','$Uploads2',
'$Uploads3', $Uploads4 )")or die(mysql_error());
echo "This Work Order has been Updated Successfully";
}
This is the part of the image script that names the images... and not sure how to get this into the query to go to the db. This information is in the second script. There are a maximum of 4 images that can be uploaded.
if ($_FILES['upload']['error'][$i] == 0)
{
$uploaddir = '/public_html/benjamin/GEUploads';
$uploadfile = $uploaddir . basename($_FILES['upload']['name'][$i]);
move_uploaded_file($_FILES['upload']['tmp_name'][$i], $uploadfile);
if (!move_uploaded_file($_FILES['upload']['tmp_name'][$i], $uploadfile))
{
die("<br><br><span>File could not be uploaded.</span>");
}
elseif (!is_uploaded_file ($uploadfile))
{
die("<br><br><span>Your file was not uploaded successfully.</span>");
}
}