Coder Social home page Coder Social logo

codeigniter-multi-upload's People

Contributors

cg-sthomas avatar korovacow avatar luclanet avatar stvnthomas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter-multi-upload's Issues

Uploading XLS doesn't work

I've tried upload an xls file and got "The file type you are attempting to upload is not allowed." I modified the first call for "is_allowed_filetype" method sending as a "true" parameter and then works.

My CI version is 2.1.3

Regards!

Resize on upload

Hi Steven,

I'm attempting to resize the images upon upload, so that I can upload images straight from the camera, where the upload will then resize them to around 1,000 pixels wide, or 600px high.

I have tried both creating thumbnails, and then even forcing the sizes in the MY_Upload library but no joy... Would it better to loop through them in the model instead?

Do you know the best way to achieve this?
Many thanks,
Chris

Advanced feature + script

See also http://www.raymondcamden.com/2013/09/10/Adding-a-file-display-list-to-a-multifile-upload-HTML-control

This will add a list before uploading the files.

<input type="file" id="files" name="files[]" multiple="" size="20" />
<br /><br /><div id="selectedFiles"></div><br />
<input type="submit" value="upload" />
<script> var selDiv = ""; document.addEventListener("DOMContentLoaded", init, false); function init() { document.querySelector('#files').addEventListener('change', handleFileSelect, false); selDiv = document.querySelector("#selectedFiles"); } function handleFileSelect(e) { if(!e.target.files) return; selDiv.innerHTML = ""; var files = e.target.files; for(var i=0; i"; } } </script>

Insert to database

QUESTION ::
How to insert the upload file into my database?
Thanks, sorry for my bad english

Problem changing filenames

I can't figure out how to change the filenames of the uploaded files.

The first file always gets the name "array.ext" and the next ones, keep their original names.

This is the code:

                // Filenames array
                $filenames_ar = array();
                $i = 0;
                foreach($_FILES['product_image']['name'] as $k => $v) {
                    // Get the file extension
                    $file_ext = explode('.', $v);
                    // Write the new filename
                    $filenames_ar[$k] = "img_{$i}";
                    $i++;
                }
                $config["file_name"] = array("{$filenames_ar}");
                $config['overwrite'] = FALSE;
                $config['allowed_types'] = 'jpg|jpeg|gif|png|bmp';
                $config['max_size'] = 2000;
                $config['upload_path'] = './images/product';
                $this->load->library('upload', $config);

                if ($this->upload->do_multi_upload('product_image')){

                }

Declaration of MY_Upload should be compatible with CI_Upload

Thanks for this wonderful extension. But I have encountered this error and I don't know how to get rid of it. Please help out.

A PHP Error was encountered

Severity: Warning

Message: Declaration of MY_Upload::initialize($config = Array) should be compatible with CI_Upload::initialize(array $config = Array, $reset = true)

Filename: libraries/MY_Upload.php

Line Number: 445

Display files that failed to upload

How can I also diplay a list of all files that failed to upload with the error occured to each one?

eg Files failed to upload:
file1 - invalid file format
file2 - filesize too big
file3 - invalid file format
etc etc

is not working

my from

Attach Files

'files[]','multiple'=>'multiple', 'class'=>'span3'); echo form_upload($data); ?>

and my controller

$this->load->library('upload');

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';

    $this->load->library('upload', $config);

    if ( ! $this->upload->do_upload("files"))
    {
        $error = array('error' => $this->upload->display_errors());

        print_r($error);

        //$this->load->view('upload_form', $error);
    }
    else
    {
        $data = array('upload_data' => $this->upload->data());

        //$this->load->view('upload_success', $data);
        print_r($data);
    }

        exit;

i m getting an error like The upload path does not appear to be valid.

if i m removed this line $this->load->library('upload'); and chnaged function do_upload its working..
wat to do?

Codeigniter 2.2.0

Please update the codeigniter multi-upload to fit codeigniter 2.2.0!

Thanks!

Upload Runtime Notice

Getting this message running Codeigniter 3.0.0 RC3

Declaration of MY_Upload::initialize() should be compatible with CI_Upload::initialize(array $config = Array, $reset = true)

Declaration of MY_Upload should be compatible with CI_Upload

A PHP Error was encountered

Severity: Runtime Notice

Message: Declaration of MY_Upload::initialize($config = Array) should be compatible with CI_Upload::initialize(array $config = Array, $reset = true)

Filename: libraries/MY_Upload.php

Line Number: 446

Backtrace:

File: C:\xampp\htdocs\codeigniter\index.php
Line: 315
Function: require_once
capture-1

Sanitize Filename & Encrypt Name issue Codeigniter 3

Hello,

Thanks for your great work to this class.

I'm quite new in CI, and try to implement your class in my project.

but, i found some issues about your class in CI 3.

  1. $this->clean_file_name already not work in CI 3, also will encounter error if i change it to $this->security->sanitize_filename / even $this->security->xss_clean.

For temporary solution i just let the code to be like this

//Sanitize the file name for security. $this->file_name = $this->file_name;

So far, it work, but i don't think it safe.

  1. Encrypt Name also not work, it return nothing when i set it to TRUE.

here's is my code
// inisialisasi upload file $config = array( 'upload_path' => $dir, 'allowed_types' => 'jpeg|jpg|png', 'overwrite' => TRUE, 'encrypt_name' => TRUE, ); // load Upload library $this->upload->initialize($config); $this->load->library('upload', $config); $this->load->library('image_lib', $config);

but when i print_r it,

the result looks like this

`Array
(
[upload_data] => Array
(

        [1] =&gt; Array
            (
                [file_name] =&gt; mbuntu_(14).jpg
                [file_type] =&gt; image/jpeg
                [file_path] =&gt; (i delete it)/HP-2/
                [full_path] =&gt; (i delete it)HP-2/mbuntu_(14).jpg
                [raw_name] =&gt; mbuntu_(14)
                [orig_name] =&gt; mbuntu_(14).jpg
                [client_name] =&gt; mbuntu (14).jpg
                [file_ext] =&gt; .jpg
                [file_size] =&gt; 111.61
                [is_image] =&gt; 1
                [image_width] =&gt; 3200
                [image_height] =&gt; 2000
                [image_type] =&gt; jpeg
                [image_size_str] =&gt; width="3200" height="2000"
            )

        [2] =&gt; Array
            (
                [file_name] =&gt; mbuntu_(20).jpg
                [file_type] =&gt; image/jpeg
                [file_path] =&gt; (i delete it)/HP-2/
                [full_path] =&gt; (i delete it)HP-2/mbuntu_(20).jpg
                [raw_name] =&gt; mbuntu_(20)
                [orig_name] =&gt; mbuntu_(20).jpg
                [client_name] =&gt; mbuntu (20).jpg
                [file_ext] =&gt; .jpg
                [file_size] =&gt; 145.02
                [is_image] =&gt; 1
                [image_width] =&gt; 2560
                [image_height] =&gt; 1600
                [image_type] =&gt; jpeg
                [image_size_str] =&gt; width="2560" height="1600"
            )

    )

)
`

Thanks in advance.

hope this issues fixed soon...

Which version?

Hello,

I am using 2.1.4. But this library doesn't work correctly. Do you have any idea?

Thanks

files dats array

Hello everyone.
Sorry for the title : files data array
Thanks for this great lib that is very helpfull.
I've read about filtering $_FILES to turn uploads optionnals but i've already a problem when I want replace one file by an other in an array.
The new uploaded file have already index #0 and no more information to know exactly what fields was used or not .
To avoid my problem, i've just wrote this to have further control on library returns.
L 222 protected function _set_multi_upload_data($i){
L 439 $this->_set_multi_upload_data($i);
In this way, I can use <input type="file" name="files[str]"> ... and merging arrays become very easy.
Ex :
$array = array ( 'str' => 'value');
$files = $this->upload->get_multi_upload_data();
foreach ( $files as $k => $v)
{
$array[$k] = $v;
}
It is very helpfull in my case, create an object from multi upload form, and I hope this tricks help someone.
If I did some mistake, i'll read your answer carefully.

Problem uploading files with empty value. solved

i found an issue when my users let one o more of my inputs empty.

i put this code line in the line 262

$_FILES[$field]["name"] = array_filter($_FILES[$field]["name"]);

and solve my problem, i hope can help to fix the problem to another user.

make file upload optional

assuming i have a form with 3 file fields, how can i make just one required and the rest optional ?
thanks

Renaming Files

Hi Steven,

Many thanks for your library!
So far it's working great, until I come to try and rename the files.
(I need to do so in order to write each file to a db).

Using your example,

$this->upload->initialize(array(
        "file_name"     => array("file_1.ext", "file_2.ext", "file_3.ext")
));

I've written an array which renames each file with it's correct file extension:

// Filenames array
$i = 0;
foreach($_FILES['files']['name'] as $k => $v) {

    // Get the file extension
    $file_ext = explode('.', $v);

    // Write the new filename
    if($i > 0) $filenames_ar .= ', "img_'.$i.'.'.$file_ext[1].'"';
    else $filenames_ar .= '"img_'.$i.'.'.$file_ext[1].'"';
    $i++ ;
}

So i get the following for $filenames_ar:

"img_0.jpg", "img_1.png"

And use it as follows:

$this->upload->initialize(array(
        "file_name"     => array($filenames_ar)
));

However, I get the error:
"The filetype you are attempting to upload is not allowed".

I've tried to populate the "file_type" in the same way but it returns the same error...

Any ideas?

Many Thanks!
Chris

Uploading autorized and non-autorized file extensions

Hi, and thanks for this library.
Example:

  • I set an upload form with only image files autorized (jpg, png, gif)
  • I try to upload... say a .jpg file and a .ini file.
  • I have the error message "upload_invalid_filetype", and no upload_data array, as expected.
  • But the problem is that the .jpg file is actually uploaded!

The correct behaviour is:

  • Either do not upload (or delete uploaded files) any file if one of theme is of incorrect type (extension, big size ...)
  • Or, fire the error message for individual, incorrect files, and return a upload_data array for the correct ones

Thanks :)

500 internal server error when uploading lots of files

I tried to upload many files and it worked perfectly but when I tried to upload like more that 50 pictures I received 500 internal server error
these are the configurations I used :

$config['upload_path'] = './uploads/screenshots/';
$config['allowed_types'] = 'jpg|jpeg|png';
$config['remove_spaces'] = TRUE;
$config['xss_clean'] = TRUE;
$config['encrypt_name'] = TRUE;
$config['max_size'] = '10240';

the error occured only when $config['xss_clean'] is set to TRUE
I tracked the code until I found that in the method do_xss_clean() in the CI_Upload class
it gives me the 500 server error when there is a return value that equals true after updating the memry limit
when I removed this line it worked fine ini_set('memory_limit', $new_memory);

I don't know for sure but I think that resetting the memory many times is the problem

Notes :

  1. I tried to display the errors by all means but no use it gave me 500 internal server error or an empty response.
  2. I already set my upload_max_filesize , post_max_size , max_file_uploads and I'm positive they work.
  3. as I said the error only occurred in this conditions otherwise it worked perfectly.

Doesnt work

YOu Library doesnt work I done what you said but dont you have to load the lib?

Oh, that's a piece of sh*t

It's the worse codeigniter library I've ever met. A lot of errors on each step (i have fixed 9), a lot of bugs, which are not working on codeigniter 3. Remove this fuc_in' sh_it from github - here's no scrapyard over here.

How to get All uploaded file names

Hello.
Please tell me how can i get all uploaded files names in Multi_upload library.
i tried using foreach and for loop but it returns only last uploaded file name in sequence. not the names of all files..
waiting for reply.

Sajid

$config['file_name'] doesn't work

When trying to set new filename for uploads (single and multiple) setting the CI config 'file_name' it doesn't seem to work with this. Instead it rather uses the original file names and won't allow me to set my own filenames :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.