jQuery-File-Upload icon indicating copy to clipboard operation
jQuery-File-Upload copied to clipboard

How to get images name in comma seprated

Open nk-nareshkumar opened this issue 14 years ago • 2 comments

I need all images name in comma separated . Bcoz i need to insert names in DB in comma separated form.

I am trying to do with this in handle_file_upload() function

$arrOfImgs = array($file->name); $comma_separated = implode(",", $arrOfImgs);

and passing this in

$file->upload_to_db = $this->add_img($comma_separated);

But getting fail.

Help Please..

protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,

        $index = null, $content_range = null) {

        $file = new stdClass();

        $file->name = $this->trim_file_name($name, $type, $index, $content_range);

        $arrOfImgs = array($file->name);

        $comma_separated = implode(",", $arrOfImgs);

        $file->size = $this->fix_integer_overflow(intval($size));

        $file->type = $type;

        if ($this->validate($uploaded_file, $file, $error, $index)) {
            $this->handle_form_data($file, $index);
            $upload_dir = $this->get_upload_path();
            if (!is_dir($upload_dir)) {
                mkdir($upload_dir, $this->options['mkdir_mode'], true);
            }
            $file_path = $this->get_upload_path($file->name);
            $append_file = $content_range && is_file($file_path) &&
                $file->size > $this->get_file_size($file_path);
            if ($uploaded_file && is_uploaded_file($uploaded_file)) {
                // multipart/formdata uploads (POST method uploads)
                if ($append_file) {
                    file_put_contents(
                        $file_path,
                        fopen($uploaded_file, 'r'),
                        FILE_APPEND
                    );
                } else {
                    move_uploaded_file($uploaded_file, $file_path);
                }
            } else {
                // Non-multipart uploads (PUT method support)
                file_put_contents(
                    $file_path,
                    fopen('php://input', 'r'),
                    $append_file ? FILE_APPEND : 0
                );
            }
            $file_size = $this->get_file_size($file_path, $append_file);
            if ($file_size === $file->size) {
                if ($this->options['orient_image']) {
                    $this->orient_image($file_path);
                }
                $file->url = $this->get_download_url($file->name);
                foreach($this->options['image_versions'] as $version => $options) {
                    if ($this->create_scaled_image($file->name, $version, $options)) {
                        if (!empty($version)) {
                            $file->{$version.'_url'} = $this->get_download_url(
                                $file->name,
                                $version
                            );
                        } else {
                            $file_size = $this->get_file_size($file_path, true);
                        }
                    }
                }
            } else if (!$content_range && $this->options['discard_aborted_uploads']) {
                unlink($file_path);
                $file->error = 'abort';
            }

            $file->upload_to_db = $this->add_img($comma_separated);

            $file->size = $file_size;
            $this->set_file_delete_properties($file);
        }
        return $file;
    }

nk-nareshkumar avatar Dec 01 '12 07:12 nk-nareshkumar

Please post support requests and general discussions about this project to the support forum: https://groups.google.com/d/forum/jquery-fileupload

The issues tracker should only be used for bugs or feature requests: https://github.com/blueimp/jQuery-File-Upload/blob/master/CONTRIBUTING.md

blueimp avatar Dec 02 '12 20:12 blueimp

eh ni hona sir gggg

singh-sta avatar Dec 04 '12 07:12 singh-sta