tags:

views:

25

answers:

1

Firefox doesn't know how to open this address because the protocol (c) isn't associated with any program... 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

+2  A: 

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;
?>
Greg