简体   繁体   English

无法使用php函数将文件从本地计算机上传到服务器

[英]Unable to upload the file from local machine to server using php function

i am uploading the file in the servier i am using the below code 我正在使用以下代码在伺服器中上传文件

   move_uploaded_file($_FILES["uploadfile".$k]["tmp_name"],
  "photoalbum/".$_SESSION["almgid"]."/".$_FILES["uploadfile".$k]["name"]);
  $uploadfile =  "photoalbum/".$_SESSION["almgid"]."/".$_FILES["uploadfile".$k]["name"];

This code is working fine in the local but the images are not uploading in the server how to solve this issue please help me, 此代码在本地工作正常,但图像未在服务器中上传如何解决此问题,请帮助我,

this is the error message i am receive during uploading the file in server 这是我在服务器中上传文件期间收到的错误消息

Warning: move_uploaded_file(photoalbum/1cutebaby05.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/whspider/public_html/alumnimgmts/editprofile.php

i am already added the enctype="multipart/form-data" in the form, i already check the image size, 我已经在表单中添加了enctype =“ multipart / form-data”,我已经检查了图像大小,

假设您正在运行Linux机器:

sudo chmod +w /path/to/photoalbum

IF they are working in local server, then it is the problem related to to authorities. 如果他们在本地服务器上工作,那么这是与授权有关的问题。

try 尝试

chmod("photoalbum/".$_SESSION["almgid"]."/",0755); // OR 0777 during testing only

before move_uploaded_file move_uploaded_file之前

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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