Welcome Guest, Not a member yet? Register   Sign In
How can I delete file from my uploads folder?
#11

[eluser]Mohammed Zayan[/eluser]
[quote author="InsiteFX" date="1336424063"]You can also try:
Code:
unset

[/quote]

I try it. It dosen't delete
#12

[eluser]Mohammed Zayan[/eluser]
[quote author="CroNiX" date="1336423234"]assuming your "uploads" directory is at the same level as your index.php...

Code:
unlink(FCPATH . 'uploads/' . $FileName);

should produce
/path/to/your/uploads/filename.jpg[/quote]

I should save filename in my database first?

I use this code
Code:
if($this->upload->do_upload()){
    $photo_data = $this->upload->data();
    $FileName =  $photo_data['file_name'];
    $photo_link = base_url() . 'uploads/' . $FileName;
}else{
    $data['message'] = $this->upload->display_errors();
}

in adding function
and I want to delete in anther function
#13

[eluser]InsiteFX[/eluser]
LOL, thats what happens when you been sitting here programming all day...

Correct it's unlink, sorry about that time for me to quit now.

Been here since 5:00 am EST buggy eyed lol

Code:
// --------------------------------------------------------------------

/**
* delete_images()
*
* Delets the users profile and resume image files.
*
* @access public
* @param string
* @return void
*/
if ( ! function_exists('delete_images'))
{
    function delete_images($user_url, $del)
    {
        $profile = APPPATH . '../public/uploads/files/' . $user_url . '/profile/';
        $resume  = APPPATH . '../public/uploads/files/' . $user_url . '/resume/';

        $file_types = '*.jpg';

        // Delete Profile Photo
        if ($del == 1)
        {
            // Find all user profile image files of the given file type and delete them.
            foreach (glob($profile . $file_types) as $file_name)
            {
                unlink($file_name);
                return;
            }
        }

        // Delete Resume Photo
        if ($del == 2)
        {
            // Find all user resume image files of the given file type and delete them.
            foreach (glob($resume . $file_types) as $file_name)
            {
                unlink($file_name);
                return;
            }
        }

        return;
    }
}
#14

[eluser]Mohammed Zayan[/eluser]
Thank you
I save in database by this code
Code:
if($this->upload->do_upload()){
    $photo_data = $this->upload->data();
    $FileName =  $photo_data['file_name'];
    $photo_link = 'uploads/' . $FileName;
}else{
    $data['message'] = $this->upload->display_errors();
}

and it works. thank you again




Theme © iAndrew 2016 - Forum software by © MyBB