Move_uploaded_file()函数不起作用 [英] Move_uploaded_file() function is not working
本文介绍了Move_uploaded_file()函数不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在网站上,希望用户能够上传文件.因此,我正在尝试学习如何做到这一点.经过研究,它说我必须使用函数move_uploaded_file().我写的代码与示例中的代码一样(更改数据),但是无法正常工作.请帮助我,我是新手.到目前为止,这是我所做的:
I'm working on a website and I want the user to be able to upload files. So I'm trying to learn how to do that. I researched and it said that I had to use the function move_uploaded_file(). I wrote the code just like it was on the example (changing the data), but it wouldn't work. Please help me, I'm new at these. Here's what I've done so far:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="upload_file.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<input type="file"name="file">
<input type="submit">
</form>
</body>
<html>
这是upload_file.php:
This is the upload_file.php:
<!DOCTYPE html>
<html>
<head>
<head>
<body>
<?php
$move = "/Users/George/Desktop/uploads/";
echo $_FILES["file"]['name']."<br>";
echo $_FILES["file"]['tmp_name']."<br>";
echo $_FILES["file"]['size']."<br>";
echo $_FILES['file']['error']."<br>";
move_uploaded_file($_FILES['file']['name'], $move);
?>
<body>
<html>
推荐答案
文件将存储在临时位置,请使用 tmp_name 代替 name
File will be stored in temporary location, use tmp_name instead of name
if (move_uploaded_file($_FILES['image']['tmp_name'], __DIR__.'/../../uploads/'. $_FILES["image"]['name'])) {
echo "Uploaded";
} else {
echo "File was not uploaded";
}
这篇关于Move_uploaded_file()函数不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文