Php文件上传无法正常工作

时间:2013-04-18 08:52:05

标签: php file-upload

我设法将图像下载到C:\ wamp \ www \ images \。但是,文件的第一个字母将被删除。我不知道为什么会这样。此外,我无法在网页上显示图像。你能帮帮我吗?

此php文件显示有关文件的信息,并且还假设显示图像但不显示。

<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>

此html表单上传图片

<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>

1 个答案:

答案 0 :(得分:3)

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