upload file problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

mikotondria
Forum Newbie
Posts: 11
Joined: Thu Jun 24, 2004 5:20 pm

Post by mikotondria »

(no joy with MAX-FILE_SIZE removed)..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you have a for loop.. which covers:

Code: Select all

<?php
for ($i=0; $i<$num_results; $i++) 
{ 
  $row = mysql_fetch_array($result); 

  if ( is_int($i/2)){ 
    echo "<tr bgcolor=#e0e0e0>"; 
  } else { 
    echo "<tr>"; 
  } 

  echo "<td valign=top>"; 
  echo "<span>"; 
  echo "<input type"text" name="title" class="dates" size="20" value="".htmlspecialchars(stripslashes($row['title']))."">"; 
  echo "</input>"; 
  echo "</span>"; 
  echo "</td>"; 

  echo "<td width=250 valign=top>"; 
  echo "<span>"; 
  echo "<textarea name="description" class="description2" rows=10 cols=50>"; 
  echo htmlspecialchars(stripslashes($row['description'])); 
  echo "</textarea>"; 
  echo "</span>"; 
  echo "</td>"; 

  echo "<input type="hidden" name="image" value="".htmlspecialchars(stripslashes($row['photo_url']))."">"; 
  echo "<input type="hidden" name="entry" value="".htmlspecialchars(stripslashes($row['entry_id']))."">"; 

  echo "<td valign=top>"; 
  echo "<span class="img2"><img src="images/".htmlspecialchars(stripslashes($row['photo_url']))."" height=100 width=100 <br><br> 
<input type="hidden" name="MAX_FILE_SIZE" value="100000"/><p> 
<input class="artist" type="file" name="image1" size="25" />";                      // HERE
  echo "</td>"; 

  echo "<td valign=top>"; 
  echo "<span class="img2"><img src="images/".htmlspecialchars(stripslashes($row['photo_url2']))."" height=80 width=80 <br><br> 
<input type="hidden" name="MAX_FILE_SIZE" value="100000"/><p> 
<input class="artist" type="file" name="image1" size="25" />";                      // HERE
         echo "</td>"; 

  echo "</tr><tr align=right><td colspan=7><input type="submit" value="Update"/>"; 
  echo "</table>"; 
  echo "</form>"; 

} 

?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there are some other errors in there.. like the image's tags aren't terminated.
mikotondria
Forum Newbie
Posts: 11
Joined: Thu Jun 24, 2004 5:20 pm

Post by mikotondria »

OK, cool - I closed the img tags, like so...

Code: Select all

<?php


echo "<td valign=top>";
echo "<span class="img2"><img src="images/".htmlspecialchars(stripslashes($row['photo_url']))."" height=100 width=100> <br><br><input class="artist" type="file" name="image1" size="25" />";
echo "</td>";

echo "<td valign=top>";
echo "<span class="img2"><img src="images/".htmlspecialchars(stripslashes($row['photo_url2']))."" height=80 width=80> <br><br>
<p>
<input class="artist" type="file" name="image1" size="25" />";
echo "</td>";


?>
regarding the loop, I suppose its unnecessary, since I am only retirieving one record, right... ?

shall I just replace that with $i =0; ?

a thousand thanks,

Mike.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it still remains that both file fields are the same name, so if you leave the second blank, it'll override the first.. maybe.. it depends on how php handles the incoming data. But I know the names need to change.
mikotondria
Forum Newbie
Posts: 11
Joined: Thu Jun 24, 2004 5:20 pm

Post by mikotondria »

ah, very sharp eyes there, thanks :)..

Looking more hopeful now, with output being

array(2) { ["image1"]=> array(4) { ["name"]=> string(12) "scan1_tn.jpg" ["type"]=> string(11) "image/pjpeg" ["tmp_name"]=> string(14) "/tmp/php8MsV8u" ["size"]=> int(2872) } ["image2"]=> array(4) { ["name"]=> string(0) "" ["type"]=> string(24) "application/octet-stream" ["tmp_name"]=> string(4) "none" ["size"]=> int(0) } } file 1 isfile 2 is

so its receiving the image, and in the error dump is showing the 'name' part of the array as being present...

Its not echoing that when I set $nameit1 to $_FILES['image1']['name'], though, as evidenced by the '..file 1 is' being blank..

Still, this seems like progress, thank you :)..
mikotondria
Forum Newbie
Posts: 11
Joined: Thu Jun 24, 2004 5:20 pm

Post by mikotondria »

aha...
My hosts helpdesk have managed to get the thing working, with no errors, so we've just got to track down why I might be getting an error where they dont.
I'll post back the solution when I get it.

Thanks so much for all your efforts, I really appreciate it :).

Mike.
Post Reply