Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Uploading One File to Multiple Directories - Best Practice?
#1

[eluser]Unknown[/eluser]
I have a form that the user can upload an image but due to the nature of my website the image can end up in multiple location.

I have a bunch of conditionals to take care of the logic however I am not sure what the best practice is in terms of one file to multiple directories do I do this:

Code:
// file configuration for upload, upload path not defined till option determination
$fileConfig['allowed_types'] = 'gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|bmp|BMP';
$fileConfig['max_size'] = '2048';
$fileConfig['max_width'] = '1920';
$fileConfig['max_height'] = '1080';
$fileConfig['remove_spaces'] = TRUE;

if ($option1 && $option2) {    
     // add file to example1 directory        
     $fileConfig['upload_path'] = '/example1/';
     $this->load->library('upload', $fileConfig);
     $this->upload->do_upload();

     // add file to example2 directory
     $fileConfig['upload_path'] = '/example2/';
     $this->load->library('upload', $fileConfig);
     $this->upload->do_upload();

Or do I just upload the file to one location and then just copy it using PHP?

Sidenote: I could not find out if allowed types is case sensitive or not. If anyone knows I would appreciate your help.




Theme © iAndrew 2016 - Forum software by © MyBB