Hi, I've got a PHP script which uses the copy function to upload a submitted image to the server.
The problem I have is that whenever i click submit, I get the following:
No Image Specified.
Notice: Undefined index: img1 in c:\pcanalyst\admin\submit.
php on line 62 < - used for testing
//////////////////////////
//////////
//////////
//////////
//////////
//////////
//////////
//////////
/////////
The form code:
//////////////////////////
//////////
//////////
//////////
//////////
//////////
//////////
//////////
/////////
<form action="submit.php?complet
e=step_1" method="post" enctype="multipart/form-da
ta">
<div id="readroot" style="display: none;">
<input value="Remove Image" class="input" onclick="this.parentNode.p
arentNode.
removeChil
d(this.par
entNode); return false" disabled="disabled" type="button">
<input name="number" value="" id="number" disabled="disabled" type="hidden">
<input name="img" size="30" class="input" disabled="disabled" type="file">
<input name="dontscale" value="1" disabled="disabled" type="checkbox">Fixed Size
</div>
<div id="" style="display: block;">
<input value="Remove Image" class="input" onclick="this.parentNode.p
arentNode.
removeChil
d(this.par
entNode); return false" type="button">
<input name="number1" value="1" id="number" type="hidden">
<input name="img1" size="30" class="input" type="file">
<input name="dontscale1" value="1" type="checkbox">Fixed Size
</div><div id="" style="display: block;">
<input value="Remove Image" class="input" onclick="this.parentNode.p
arentNode.
removeChil
d(this.par
entNode); return false" type="button">
<input name="number2" value="2" id="number" type="hidden">
<input name="img2" size="30" class="input" type="file">
<input name="dontscale2" value="1" type="checkbox">Fixed Size
</div><span id="writeroot"></span>
<br>
<input name="id" value="103" type="hidden">
<input name="edition" value="1" type="hidden">
<input value="Continue" onclick="return confirmSubmit()" class="input" type="submit">
</form>
//////////////////////////
//////////
//////////
//////////
//////////
//////////
//////////
//////////
/////////
submit.php:
//////////////////////////
//////////
//////////
//////////
//////////
//////////
//////////
//////////
/////////
<?php
//
// Start Step Check
//
if (isset($_GET['complete']))
{
if ($_GET['complete'] = "step_1"){
$step_1 = true;
}
elseif ($_GET['complete'] = "step_2"){
$step_2 = true;
}
elseif ($_GET['complete'] = "step_3"){
$step_3 = true;
}
elseif ($_GET['complete'] = "step_4"){
$step_4 = true;
}
} else {
echo "What are you doing here?";
}
//
// End Step Check
//
//
// Start Step 1
//
if (isset($step_1) && $step_1 = true){
set_time_limit(0);
$edition = $_POST['edition'];
$id = $_POST['id'];
if (!is_dir("../images/magazi
ne/$editio
n")){
mkdir ("../images/magazine/$edit
ion", 0755);}
if (!is_dir("../images/magazi
ne/$editio
n/articles
/$id")){
mkdir ("../images/magazine/$edit
ion/articl
es/$id", 0755);}
if (!is_dir("../images/magazi
ne/$editio
n/articles
/$id/not_s
caled")){
mkdir ("../images/magazine/$edit
ion/articl
es/$id/not
_scaled", 0755);}
if (!is_dir("../images/magazi
ne/$editio
n/articles
/$id/main"
)){
mkdir ("../images/magazine/$edit
ion/articl
es/$id/mai
n", 0755);}
if (!is_dir("../images/magazi
ne/$editio
n/articles
/$id/thumb
s")){
mkdir ("../images/magazine/$edit
ion/articl
es/$id/thu
mbs", 0755);}
$x = 1;
if(isset($_POST['img1'])){
while (isset($_POST['img'.$x])){
echo "image $x is set";
$number = $x;
if(isset($_POST['dontscale
'.$x]) && $_POST['dontscale'.$x] == "1"){
copy($_POST['img'.$x] , "../images/magazine/$editi
on/article
s/$id/not_
scaled/$x.
jpg")
or die("Couldn't Upload File 1.");
echo "Image Submitted Successfully.";
} else {
copy($_GET['img'.$x] , "../images/magazine/$editi
on/article
s/$id/main
/$x.jpg")
or die("Couldn't Upload File 1.");
echo "Image Submitted Successfully.";
}
$x++;
}
} else {
echo "No Image Specified.<br>";
echo $_POST['img'.$x]; // used for testing
}
}
//
// End Step 1
//
?>
//////////////////////////
//////////
//////////
//////////
//////////
//////////
//////////
//////////
/////////
Any help you can give me would be greatly appreciated. I've been trying to solve this problem for 5 hours now.
Start Free Trial