Reputation: 465
Below is a main page for uploaded page:
<form id="form1" method="post" action="display.php" enctype="multipart/form-data" id="pro_image">
<input type='file' onchange="readURL(this);" name="image" id="image"/>
<br><img id="blah" src="profile pic.jpg" alt="your image" width="160px" height="120px"/><br/>
</form>
Incorporated with the image display page(display.php) script:
<?php
$dir="upload/";
$name=$_FILES['image']['name'];
$tmp=$_FILES['image']['tmp_name'];
move_uploaded_file($tmp,$dir.$name);
?>
<br /><img src="".$dir.$name."" width="100" height="100"/>
Anyone can help me to point out what the actual problem on display.php
and correct my script?The image didn't show as desired on the page.
the output of display.php as show above:
Upvotes: 2
Views: 599
Reputation:
Your display.php
file is a php file and you are try to show the variable data without echoing it in this file use it.
<img src="<?php echo $dir.$name; ?>" width="100" height="100"/>
EDITED:
move_uploaded_file($tmp,$dir.$name) or die("There is error in uploading");
Upvotes: 1
Reputation: 1153
As first thing check that ur images uploaded properly on uploads/ folder. there is changes of permission issue to upload the images.
then check manually accessing images by giving URL http://test.com/uploads/image1.jpg
if all this debug with firebug what path is getting shown in
if this path is wrong try to use absolute path rather than relative.
Upvotes: 0
Reputation: 30488
you forgot <?php ?>
here
<img src="<?php echo $dir.$name; ?>" width="100" height="100"/>
Upvotes: 4