Jump to content


Photo

Images


  • Please log in to reply
5 replies to this topic

#1 iamali

iamali
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 02 March 2006 - 03:45 PM

Does anyone know what would cause images not to load? I'm displaying images after I upload them using this code:

<a href="<?php echo $_FILES['file']['name']; ?>"><img src="<?php echo $_FILES['file']['name']; ?>" height="200"></a>

but it's not working!
Anyone?!

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 02 March 2006 - 04:28 PM

is your form like..

<form name="form1" enctype="multipart/form-data" method="post" action="">


Are you sure u have enctype="multipart/form-data" in the form eliment? maby post full code?
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 iamali

iamali
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 02 March 2006 - 04:47 PM

[!--quoteo(post=351004:date=Mar 2 2006, 04:28 PM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 2 2006, 04:28 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
is your form like..

<form name="form1" enctype="multipart/form-data" method="post" action="">
Are you sure u have enctype="multipart/form-data" in the form eliment? maby post full code?
[/quote]

yeah, my form is:

<html><head><title>File Uploader</title></head>
<body><h3>File Upload</h3>
Select a file to upload:<br>
<form action="uploader.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" size="45">
<br>
<input type="submit" value="Upload File">
</form>
</body></html>

and the uploading script is:

<?php
if( $_FILES['file']['name'] != "" )
{
copy ( $_FILES['file']['tmp_name'],
"C:/Inetpub/wwwroot/Upload/" . $_FILES['file']['name'] )
or die( "Could not copy file" );
}
else{ die( "No file specified" ); }
?>

<html>
<head><title>Upload Complete</title></head>
<body>
<h3>File Upload Succeeded...</h3>

<ul>
<li>Sent: <?php echo $_FILES['file']['name']; ?>
<li>Size: <?php echo $_FILES['file']['size']; ?> bytes
<li>Type: <?php echo $_FILES['file']['type']; ?>
</ul>

<a href="<?php echo $_FILES['file']['name']; ?>"><img src="<?php echo

$_FILES['file']['name']; ?>" height="200"></a>

</body>
</html>

:-)

#4 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 02 March 2006 - 04:56 PM

<html><head><title>File Uploader</title></head>
<body><h3>File Upload</h3>
Select a file to upload:<br>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file" size="45">
<br>
<input type="submit" value="Upload File">
</form>
</body></html>

and the uploading script is: 

<?php
if( $_FILES['file']['name'] != "" )
{
copy ( $_FILES['file']['tmp_name'],
"/var/www/stuff/" . $_FILES['file']['name'] )
or die( "Could not copy file" );
}
else{ die( "No file specified" ); }
?>

<html>
<head><title>Upload Complete</title></head>
<body>
<h3>File Upload Succeeded...</h3>

<ul>
<li>Sent: <?php echo $_FILES['file']['name']; ?>
<li>Size: <?php echo $_FILES['file']['size']; ?> bytes
<li>Type: <?php echo $_FILES['file']['type']; ?>
</ul>

<a href="<?php echo "http://www.blucode.net/stuff/".$_FILES['file']['name']; ?>"><img src="<?php echo "http://www.blucode.net/stuff/".$_FILES['file']['name']; ?>" height="200"></a>

</body>
</html>

that works for me.. [a href=\"http://www.blucode.net/phpfreaks.php\" target=\"_blank\"]http://www.blucode.net/phpfreaks.php[/a] was u running your page in the folder "Upload" ??
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#5 iamali

iamali
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 02 March 2006 - 05:24 PM

[!--quoteo(post=351018:date=Mar 2 2006, 04:56 PM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 2 2006, 04:56 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]

that works for me.. [a href=\"http://www.blucode.net/phpfreaks.php\" target=\"_blank\"]http://www.blucode.net/phpfreaks.php[/a] was u running your page in the folder "Upload" ??
[/quote]

yeah, it's in the folder upload. wondering whether it's something to do with my setup of PHP but i'd have no idea what it would be :-S

#6 iamali

iamali
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 02 March 2006 - 05:36 PM

[!--quoteo(post=351018:date=Mar 2 2006, 04:56 PM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 2 2006, 04:56 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
that works for me.. [a href=\"http://www.blucode.net/phpfreaks.php\" target=\"_blank\"]http://www.blucode.net/phpfreaks.php[/a] was u running your page in the folder "Upload" ??
[/quote]

ooh i got the images to to show up with:

<?php
if( $_FILES['file']['name'] != "" )
{
copy ( $_FILES['file']['tmp_name'],
"C:Inetpub/wwwroot/Upload/" . $_FILES['file']['name'] )
or die( "Could not copy file" );
}
else{ die( "No file specified" ); }
?>

<html>
<head><title>Upload Complete</title></head>
<body>
<h3>File Upload Succeeded...</h3>

<ul>
<li>Sent: <?php echo $_FILES['file']['name']; ?>
<li>Size: <?php echo $_FILES['file']['size']; ?> bytes
<li>Type: <?php echo $_FILES['file']['type']; ?>
</ul>

<a href="<?php echo "C:/Inetpub/wwwroot/Upload/".$_FILES['file']['name']; ?>"><img

src="<?php echo "C:/Inetpub/wwwroot/Upload/".$_FILES['file']['name']; ?>"

height="200"></a>

</body>
</html>

!!!
but the <a href part seems to link to file:///C:/Inetpub/wwwroot/Upload/filename.gif for some reason...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users