PHP:move_upload_file不起作用 [英] PHP: move_upload_file not working

查看:144
本文介绍了PHP:move_upload_file不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为team1-> uploads-> upload_file.php文件的文件夹。 upload_file.php上传一个文件,但必须把它放在上传目录,所以我用../上去一个文件夹。我有

I have a folder called team1->uploads->upload_file.php file. upload_file.php uploads a file but has to put it in the uploads directory so I was using ../ to go up a folder. File permissions are 700. I have

  move_uploaded_file($_FILES["file"]["tmp_name"],
  "../uploads/".$_FILES["file"]["name"]);

我得到以下错误:

I get the following error:

Warning: move_uploaded_file(../uploads/profile.jpg): failed to open stream: Permission denied in        D:\inetpub\wwwroot\vhosts\cs5339\team1\Produce\upload_file.php on line 31 Warning:     move_uploaded_file(): Unable to move 'C:\Windows\Temp\php938F.tmp' to '../uploads/profile.jpg' in    D:\inetpub\wwwroot\vhosts\cs5339\team1\Produce\upload_file.php on line 31 registered



任何人都知道如何解决这个问题?是否有另一种上传文件的方法?

Anyone know how to fix this? Is there another way to upload files?

推荐答案

在上传文件夹中设置权限为777,可以直接在文件夹上或使用PHP:

set permissions to 777 on the uploads folder, you can do that directly on the folder or using php:

chmod("../uploads/", 777);

这篇关于PHP:move_upload_file不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆