Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Upload Problem

Status
Not open for further replies.

reidgivens

Technical User
Mar 24, 2003
24
0
0
US
I have two forms, one to add information to a mysql database and one to edit information in the same db.

Both forms submit pages are almost identical, but on the add form set, it uploads images just fine, but on the edit book one (using the same code) no $_FILE variables are set. Its like nothing ever gets to the submit page.

Although I can't see how this would make any differnece, here is the coping code used in both pages


<---------------- code start

if(!empty($_FILES['image'])){
$filename=$_FILES['image']['name'];
$copyto=&quot;../images/books/&quot;.$filename;
if(!$copy=copy($_FILES['image']['tmp_name'],$copyto)){
die(&quot;image upload failed&quot;);
}
} else {
$filename='spacer.gif';
}

<---------------- code end

Reid Givens
Webdeveloper
 
can u give me the <form> tag of the edit page?

Known is handfull, Unknown is worldfull
 
As far as I can tell, no, the form isn't uploading the file, but its a copy of a form that does.

Here it is:

<---------------------------------code start

if(empty($_GET['idnum'])){
header(&quot;Location: editbook.php?msg=No%20IDnum%20Received&quot;);
} else {
$idnum=$_GET['idnum'];
}

include(&quot;../db/db_conn.php&quot;);

$sql=&quot;SELECT * FROM books WHERE idnum=$idnum;&quot;;

if(!$didsql=mysql_query($sql,$didopen)){
print &quot;ERROR &quot;.mysql_error();
} else {
$info=mysql_fetch_row($didsql);
}

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;editbooksql.php&quot;>
<table border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot;>
<tr>
<td colspan=&quot;2&quot; bgcolor=&quot;#999999&quot;><center>
<b>EDIT A BOOK</b> </center></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>Title:</b></font></td>
<td><input name=&quot;title&quot; type=&quot;text&quot; id=&quot;title&quot; value=&quot;<? echo($info[1]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>Author:</b></font></td>
<td><input name=&quot;author&quot; type=&quot;text&quot; id=&quot;author&quot; value=&quot;<? echo($info[2]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>ISBN number:</b></font></td>
<td><input name=&quot;isbnnum&quot; type=&quot;text&quot; id=&quot;isbnnum&quot; value=&quot;<? echo($info[3]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>SD number:</b></font></td>
<td><input name=&quot;sdnum&quot; type=&quot;text&quot; id=&quot;sdnum&quot; value=&quot;<? echo($info[4]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>Subjects:</b></font></td>
<td><input name=&quot;subjects&quot; type=&quot;text&quot; id=&quot;subjects&quot; value=&quot;<? echo($info[5]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>Catagory:</b></font></td>
<td><input name=&quot;catagory&quot; type=&quot;text&quot; id=&quot;catagory&quot; value=&quot;<? echo($info[11]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>Binding:</b></font></td>
<td><input name=&quot;binding&quot; type=&quot;text&quot; id=&quot;binding&quot; value=&quot;<? echo($info[6]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>Page count: </b></font></td>
<td><input name=&quot;pagecount&quot; type=&quot;text&quot; id=&quot;pagecount&quot; value=&quot;<? echo($info[7]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>Actual page count:</b></font></td>
<td><input name=&quot;acpagecount&quot; type=&quot;text&quot; id=&quot;acpagecount&quot; value=&quot;<? echo($info[8]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>Price:</b></font></td>
<td><input name=&quot;price&quot; type=&quot;text&quot; id=&quot;price&quot; value=&quot;<? echo($info[9]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>Size:</b></font></td>
<td><input name=&quot;size&quot; type=&quot;text&quot; id=&quot;size&quot; value=&quot;<? echo($info[10]); ?>&quot;></td>
</tr>
<tr>
<td><font size=&quot;2&quot;><b>Image:</b></font></td>
<td><? echo($info[12]); ?>
<input name=&quot;curr&quot; type=&quot;hidden&quot; id=&quot;curr&quot; value=&quot;<? echo($info[12]); ?>&quot;></td>
</tr>
<tr>
<tr>
<td><font size=&quot;1&quot;>Upload a New Image</font></td>
<td><input name=&quot;image&quot; type=&quot;file&quot; id=&quot;image&quot; value=&quot;&quot;></td>
</tr>
<td colspan=&quot;2&quot;><center>
<input name=&quot;idnum&quot; type=&quot;hidden&quot; id=&quot;idnum&quot; value=&quot;<? echo($info[0]); ?>&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
<input name=&quot;Reset&quot; type=&quot;reset&quot; id=&quot;Reset2&quot; value=&quot;Reset&quot;>
</center></td>
</tr>
</table>
</form>

<---------------------------------code end

Any idea?

Reid Givens
Webdeveloper
 
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;editbooksql.php&quot; enctype=&quot;multiple/form-data&quot;>

does this help?


Known is handfull, Unknown is worldfull
 
I don't remeber if I had tried this yet or not, I will give it a shot and post any problems, but I know the add a new record form doesn't specify and enctype and it works. Just one of those things, I guess.

Thanks guys. If this is the problem, I'm going to shoot myself for such a dumb mistake.

Reid Givens
Webdeveloper
 
dumb is a relative word, apllicable to all... :)

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top