简体   繁体   中英

Php File-uploading doesn't work properly

I manage to download the image to C:\\wamp\\www\\images\\ . However the file's first letter is deleted. I don't know why this is happening. Also, I can't display the image on the webpage. Can you help me out,please?

This php file displays the info about file and also suppose to display image but it doesn't.

<html><head><title>File Uploads</title></head>
<body bgcolor="#33ff33">
<font face="verdana" size="+1">
<?php
   echo "The uploaded file is: ", $_FILES['picture_file']['tmp_name'], "<br />";
   $filename=$_FILES['picture_file']['name'];
   $filesize=$_FILES['picture_file']['size'];
   echo "filename".$filename;
   $directory='C:\wamp\www\images\\';
   $uploadFile = $directory . $filename;
   echo "The moved file is: $uploadFile<br />";
   if (move_uploaded_file($_FILES['picture_file']['tmp_name'],
   $uploadFile)){
   echo "The file is valid and was successfully uploaded.
   <br /> ";
   echo "The image file, $filename, is $filesize bytes.<br 
   />";
}

?>

<br/>

 <img src=<?php
    echo "\"c:\wamp\www\images\\$filename\""?>>

</font>
</body>
</html>

This html form to upload image

<html><head><title>Uploading Pictures</title></head>
<body bgcolor="lavender">
<h3>Uploading Files</h3>
<form
 enctype="multipart/form-data"
 action="upload_move_file.php"
 method="post">
 Browse and select the picture you want to upload: <br />
<input name="picture_file" type="file" />
<br />
<input type=submit value="Get File"/>
</form>
</body>
</html>

如果“ www”是您的文档根目录,则图像源将是“ / images / $ filename”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM