November 18, 2010

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

Question by Meena

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,

Answer by Starx

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

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!