Welcome Guest, Not a member yet? Register   Sign In
delete file which I uploaded from the website itself
#1

[eluser]pieter dekker[/eluser]
Hi!

I have several images on the webserver, when I log in, I want to delete or upload images. I used the File Uploading class for uploading my images.
But I can't delete them, if I use unlink, I got a message that Safe Mode restriction is on. 'The script whose uid is 66775 is not allowed to access / owned by uid 0'

How can I delete images from the webserver??
#2

[eluser]Phil Sturgeon[/eluser]
Either turn off safe mode (that things causes me more issues than it would if it was off half the time...), or CHMOD newly uploaded files so you have better access.

You could always use the FTP class to delete them if that doesnt work? I do all my file management with FTP, upload EVERYTHING to a temp folder then use FTP to put it in the right place on your webserver. Means only one place needs 777 and only ONE place could possibly be attacked instead of loads.
#3

[eluser]pieter dekker[/eluser]
I manually Chmodded al the files to 777 including the containing maps (for now)

Now i uploaded a image with the upload class from CI.

Then I tried to delete the file with the FTP class from CI, but still couldn't delete the file, the only error I got was, Couldn't delete the file.

So what am I missing here?
#4

[eluser]Phil Sturgeon[/eluser]
I mean when you upload the file you need to set ownership permissions and make it writeable in the code.

Just use $this->ftp->delete_file('/home/path/images/file.gif');
#5

[eluser]pieter dekker[/eluser]
Ok, I got that with the chmod during upload, but I did it manually to test the delete function.

I used the delete_file function from the ftp class, but it gave an error, it only says, couldn't delete the file. Nothing else

I just also checked the mkdir function from the ftp class, but this function also didn't work, and only gave a message, cannot create directory Sad

So it looks like the ftp functions just don't work, but what could be the problem?
#6

[eluser]Phil Sturgeon[/eluser]
Make sure you have the paths right, the FTP lib always gets me confused with that. Echo out the path its trying to delete and make sure its the full server path to the file. Remeber you are connecting to your own server and treating it like a remote server.
#7

[eluser]pieter dekker[/eluser]
Thx for your reactions!!

I'm a step further now, creating a new directory works!
But deleting won't work Sad

I use this for creating af directory:
Code:
$this->ftp->mkdir('/public/sites/www.accessroosendaal.nl/afnemers/'.$afnemerid, 0777);

And this for deleting:
Code:
$this->ftp->delete_dir('/public/sites/www.accessroosendaal.nl/afnemers/'.$afnemerid);
#8

[eluser]frenzal[/eluser]
I would like to dig up this thread to check if anyone got the delete function working as expected? I've successfully used the upload and mkdir function, but deleting with a path I first confirmed with list_files() won't work.. Sad
#9

[eluser]mrliam69[/eluser]
I'm having the same problem here..

When I create a directory with MKDIR I can delete it straight away no problem.
But once I have upload a file to it using the upload routine the pictures can't be deleted and so neither can the directory but I can rename the directory.

Any reson why this is happening ?

Code:
function do_upload()
    {
        $this->freakauth_light->check('admin');  
        
        $config['upload_path'] = 'public/images/gallery/portfolio/'.$_POST['uploaddirectory'];
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '100';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            
            //$this->load->view('upload_form', $error);
            
            echo '$error';
        }    
        else
        {    $upload_data = $this->upload->data();
            // ============================================
            // Returns the upload data for checking
            // ============================================
            //foreach($upload_data as $item => $value):
            //   echo '<li>'.$item.': '.$value.'</li>';
            // endforeach;
            // ============================================
            
            // add database insert information
             $data = array(
               'PortfolioDir' => $_POST['uploaddirectory'],
               'PortfolioFile' => $upload_data['file_name']
                            );

                $this->db->insert('Portfolio', $data);
            
            $data = array('upload_data' => $this->upload->data());
            
            redirect('/admin/galleryedit/'.$_POST['uploaddirectory']);        
            //$this->load->view('upload_success', $data);
        }




Theme © iAndrew 2016 - Forum software by © MyBB