开发者

cant view image after uploaded via php... only explorer works!

Firefox doesn't know how to open this address because the protocol (c) isn't associated with any program... 开发者_Go百科This is the error message I get when I try to view an image uploaded by the below script:

Also, its not only firefox, chrome doenst show the image also, but Explorer does...!

The image does get uploaded!

PHP:

      <?php
      $destination_path = "C:/wamp/www/sv/main/temp_images/";
      //echo $destination_path;
       $result = 0;
        $target_path = $destination_path . basename($_FILES['pic_file']['name']);
       //echo $target_path;
       if(@move_uploaded_file($_FILES['pic_file']['tmp_name'], $target_path)) {
       $result = 1;
        }
       echo $target_path;
       $display_image="<img src='$target_path'>";
        echo $display_image;
       ?>

Even after uploaded the image, and if I take the images path and paste it in the adress bar in firefox, it gives me the same error message.

Why? What should I do?

Thanks


You need to set src to a path on the web server, not on your hard drive. Something like:

<?php
$destination_path = "C:/wamp/www/sv/main/temp_images/";
$filename = basename($_FILES['pic_file']['name']);
$result = 0;
if(@move_uploaded_file($_FILES['pic_file']['tmp_name'], $destination_path . $filename)) {
    $result = 1;
}

$display_image = "<img src='/sv/temp_images/$filename'>";
echo $display_image;
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜