dongxi5494 2013-12-02 04:39
浏览 50
已采纳

在服务器上传图像和视频

I want to upload video and images in database on server. I used following code, but when I use this code in my localhost then it works but when I upload through the server, it shows errors.

Here is my code:

$target = "upload/"; 
$target = $target . basename( $_FILES['uploaded']['name']) ; 
$ok=1; 
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{
echo "The file ".basename( $_FILES['uploaded']['name']). " has been uploaded";
} 
else {
echo "Sorry, there was a problem uploading your file.";
}

And here are the error messages:

Warning: move_uploaded_file(upload/logo.JPG) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\vhosts\hiznherzbridalshow.com\httpdocs \hiznherz_new\test2.php on line 31

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
'C:\Windows\Temp\php7648.tmp' to 'upload/logo.JPG' in C:\Inetpub\vhosts \hiznherzbridalshow.com\httpdocs\hiznherz_new\test2.php on line 31

  • 写回答

1条回答 默认 最新

  • doujue6196 2013-12-02 04:41
    关注

    PHP provides a function, chmod() for the task. Change your folder permissions manually or dynamically.

    Change your folder permission into 775 or 777

    Updated

    add this code into your php

    chmod("upload", 0777);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入