php move_uploaded_file,移动时图像变为小红色x图标

I am trying to upload images and transfer them immediately to a specific folder.

Here's my code:

    $file_path = "assets/placervw_photo/";
    $file_path = $file_path . $_FILES['uploaded_file']['name'];
    if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $file_path))
    {
        echo "success";
    }

The page displays "success" but when I check the folder, it contains the file, having the same filename and file type, but it turns into a smal red X icon with white background. Here's a look: http://s14.postimg.org/ifoiyzde5/red_x.png

I have tested it to jpg and png files and they had the same outcome.

Any suggestions on how I can solve this? Thanks in advance! :)

The "little red X" is your browser way of saying "There's no image here".

Are you trying to display the image in the same page in which you upload it? You cannot. You already sent some content which is not image, so trying to signal the browser "I've got an image here" would get you a tiny red X.

You need to send a IMG URL with the proper URL prefix:

$url = "http://yourserver.com/path/to/".$file_path;

echo "Success, here's your image: <img src=\"$url\" />";

You'd probably also do well to not trust the user's file name, but assign a random ID of your choice, and also verify that it is indeed an image (you can use getImageSize(), also to verify the extension matches the MIME type). Just in case someone sends you a 'picture' called "../../../pwn3d.php": it's been known to happen.