Ftp craeting folder and setting permission with php - php

I am making uploading site that creates folder for each user to store his pics in , i tried to make the folder with the php normal function mkdir and setting the permissions to 0777 it's creating the folder but i cant add files from the php program only copying through windows explorer in the ftp server , but if i made the folder through ftp server and set the permissions manually it worked and uploaded pics , so i tried the ftp_mkdir with the following code :
$uploaddir="httpdocs/pics/".$uid.$uname;
if(!is_dir ($uploaddir))
{
ftp_mkdir($conn, $uploaddir);
ftp_chmod($conn,"0777", $uploaddir);
}
ftp_close($conn);
it's creating the folder but not with full permissions so you cant upload files to the folder until you set the permissions manually then it works fine

Related

Permissions to files after upload with php

I having a problem which when files are uploaded to there folder with PHP they don't have any permissions to then view them on my website.
I'm using IIS and the IIS permission doesn't get set when the folder has the correct permissions.
Because what I'm doing it uploading the file location to my database then using that to display it on page if i change the file permissions it works fine but i would have to do this every time something is uploaded to my server.
Thanks,

Upload path on Codeigniter gives error in Openshift

I am trying to upload image to my Codeigniter application hosted on Openshift. My app structure is as follows
App
-libs
-...
-php
- application
- public
- uploads
I want to upload images to this uploads folder. my code
$config['upload_path']=realpath(dirname(__FILE__)).'public/uploads/';
$config['allowed_types']="jpg|jpeg|gif|png";
$this->load->library('upload',$config);
if(!($this->upload->do_upload())){
$error=array('error'=>$this->upload->display_errors());
$this->load->view('profile',$error);
}
else{
$file_data=$this->upload->data();
$data['img']=base_url().'/public/uploads/'.$file_data['file_name'];
$this->load->view('success',$data);
}
But above gives me The upload path does not appear to be valid. error. I have tried several ways. But the problem is the server do not allow to upload to the location.
Normally I can access the files in the uploads folder. But when I try to write data (store file) it doesn't allow. How can I fix this thing.
Note: I want the solution for the Openshift server but not the localhost
The path is supposed to be $OPENSHIFT_DATA_DIR (which points to ~/app_root/data).
You can also write to /tmp but those files will be treated as ephemeral.
You do not have write permissions anywhere in the file system.

allow php rwx on created dir using mkdir()

When ever my user "apache" creates a directory, I cannot add new files onto it via php upload, i have to change the folder's permissions for it to work.
how do i ensure that when a user uploads a file and a folder is created automatically by php, that file will be added onto that folder after creation, without it giving me a unwrittable folder error?
Try something like the following:
mkdir($newdirectory);
chmod($newdirectory, 0777);

Ftp folder permission not granted

I have ftp server which store my websites uploaded files. I am putting uploaded images into "upload" directory and then displaying on them to webpages with link to my photo editor tool.
Some how I can not access my ftp files in my photo editor. I figured that it is permission problem, but when I go to change permission for my upload directory files it fails to changes and says
"CHMOD 777 realtors.jpg: Operation not permitted."
let me know if any idea on how to solve this.

Setting permissions in PHP on server

I am trying to create a really simple webpage in php, letting people upload images to a folder on my server. I made this really simple with some done code, and it worked awesomely on my computer with xampp, but when I upload the page to my server, it gets an error message every time I upload anything. The error is when the script checks if the image was uploaded, where it says
$copied = copy($_FILES['image']['tmp_name'], $newname);
if(!$copied)
echo "error";
This leads me to believe that there is something wrong with the permissions. But how can I set this? And what should I set it to? I just need others to be able to upload images to a spesific folder.
The web server needs write permissions to be able to write into the directory you're storing the images.
Assuming you're on a Linux server, run the following command on the server (ssh) after changing /path/to/uploaded/images to the image upload directory, and see if it solves the problem:
chmod 777 /path/to/uploaded/images
If that fixes the problem, you can probably relax the permissions to something like:
chmod 664 /path/to/uploaded/images
These are basic commands for directory permissions, which you can learn more about in this tutorial about file permissions on Linux.
Alternatively, you can use move_uploaded_file() to copy the uploaded file to a known location.

Categories