Welcome Guest, Not a member yet? Register   Sign In
uploadify problem
#1

[eluser]zeromechanic[/eluser]
Hello guys, I can't get something to work.

I use uploadify to upload photo's.

everything is working so far.

the images end up in the folder where they should be.

The only thing not working is posting back the response to controller.
This response doesnt work.

when i comment out the filearray: response, i get the response back from the controller.

Code:
'onComplete'   : function (event, queueID, fileObj, response, data) {
//Post response back to controller
alert(response);
$.post('<?php echo site_url('admin/projecten/upper');?>',{filearray: response},function(info){

The alert is filling with a json_encoded array from the upload script.
Why isnt this working.

using this on a codeigniter 2.0.0
#2

[eluser]zeromechanic[/eluser]
found what was doing this.

Code:
$config['csrf_protection'] = TRUE;
this prevented that the postback to the controller didn't work !!!!!

Is there a way to enable/disable this per controller(function)
Or is the config the only option?
#3

[eluser]danmontgomery[/eluser]
This has been answered relatively recently, try searching. You can do it in the config file, or a pre-system hook.
#4

[eluser]zeromechanic[/eluser]
Must been using the wrong keywords.
Could you point me to teh topic??

Bypassed it my self.

added the token into the $.post, and it works fine now

thank for response


Code:
$.post('<?php echo site_url('admin/projecten/upper');?>',
{
    filearray: response,
    <?=$this->security->csrf_token_name?>: '<?=$this->security->csrf_hash?>'
},
function(info){
#5

[eluser]NiconPhantom[/eluser]
Hi, I am also using Uploadify + CI uploading class, and it works fine form me Smile

If you need to send response back to controller, I recommend you to use the default functionality of Uploadify - ScriptData parameter (http://www.uploadify.com/documentation/o...criptdata/) which sends post data to your controller and there you can use the standart $input->post('whatever').

As an example of my Uploadify configuration:

Code:
[removed]
$(document).ready(function(){
                                        
$("#upload").uploadify({
                                                        uploader: '<?php echo base_url();?>public/backend/js/uploadify/uploadify.swf',
                                                        script: '<?php echo base_url();?>admin/media/upload',
                                                        cancelImg: '<?php echo base_url();?>public/backend/js/uploadify/cancel.png',
                                                        
                                                        'fileExt'     : '*.jpg;*.gif;*.png',
                                                        'fileDesc'    : 'Image Files',
                                                        'multi': true,
                                                        'auto': true,
                                                        'wmode': 'transparent',
                                                        'queueID': 'actions',
                                                        'method'      : 'post',
                                                        'scriptData': { 'category': <?=$id?> },

                                                        'onError' : function (a, b, c, d) {
                                                                 if (d.status == 404)
                                                                        alert('Could not find upload script.');
                                                                 else if (d.type === "HTTP")
                                                                        alert('error '+d.type+": "+d.status);
                                                                 else if (d.type ==="File Size")
                                                                        alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');
                                                                 else
                                                                        alert('error '+d.type+": "+d.text);
                                                                },'onAllComplete' : function() {
                                                                 //alert(currentCategory);
                                                            loadContent(currentCategory);

    }
                                                                });
                });


        [removed]


As result of 'scriptData': { 'category': <?=$id?> } you can use $this->input->post('category') in your controller.
#6

[eluser]zeromechanic[/eluser]
My uploader was working correctly in codeigniter 1,7....., but not in CI 2.0.x
I already use the scriptdata, for my albums, id's etc.

The images where correctly placed in the right place.
But did not get a response from my controller/function for resizing,
The resize did not work, original images where in the folder(the big ones)

apperently the $config['csrf_protection'] was set to true, so codeigniter discarded the $_POST.

What is did is add the csrf token to the $.post and it is back up again.
uploading and resizing

other question,
you are using an controller to upload, when i use this I get the response cannot find uploadscript.
What am i missing there
#7

[eluser]NiconPhantom[/eluser]
Hi,

My function is as follow:

Code:
function upload()
        {
        $config['upload_path'] = './uploads/full/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '0';
        $config['max_width']  = '0';
        $config['max_height']  = '0';
                $config['encrypt_name']  = TRUE;
                $config['overwrite']  = FALSE;
                
        $this->load->library('upload', $config);


        if(! $this->upload->do_upload('Filedata'))
                {echo $this->upload->display_errors(); echo "0";}

                else{
                    $uploaded = $this->upload->data();
                    $ufile = array('name' => $uploaded['file_name'],'category' => $this->input->post('category'), 'order' => '');
     $this->db->insert('filemanager_files', $ufile);
                    $this->load->library('image_moo');

$this->image_moo->load($uploaded['full_path'])->resize_crop(100,100)->set_jpeg_quality(100)->save('./uploads/thumbs/'.$uploaded['file_name']);

                    echo "1";}
                            

        }

For the resizing I am using very nice image_moo library. I guess your problem can be in not specifyed echo "0" if error occures and echo "1" if everything is fine :-)

and of course, make sure that you're using correctly specifyed path for your custom upload script, in my environment I am using(check one of my comments with uploadify config) :

uploader: '<?php echo base_url();?>public/backend/js/uploadify/uploadify.swf',
script: '<?php echo base_url();?>admin/media/upload',
cancelImg: '<?php echo base_url();?>public/backend/js/uploadify/cancel

It's very important to have in config/mimes.conf all allowed for uploading file types in format:

Code:
'gif'    => array('image/gif', 'application/octet-stream'),
'jpeg'    =>    array('image/jpeg', 'image/pjpeg','application/octet-stream'),
'jpg'    =>    array('image/jpeg', 'image/pjpeg','application/octet-stream'),
'jpe'    =>    array('image/jpeg', 'image/pjpeg','application/octet-stream'),
'png'    =>    array('image/png',  'image/x-png','application/octet-stream'),

...etc, otherwise your files will not be uploaded with CI upload class!
#8

[eluser]ashwini[/eluser]
Hello all,
I am newbie in PHP .
I have used uploadify function in my application to upload photos, and it's working good. My problem is after uploading these photos i am resizing them to show it to user that photos are uploaded successfully. Now when images are above 1MB or 1MB , uploaded successfully in my destination folder but these images are not following resize function it's generating error on clients server (ie. I can't show images in thumbnail):-
Out of memory (allocated 19136512) (tried to allocate 10224 bytes) in /home/users/web04/9/0/0163509/www.aivan-co.jp/system/libraries/Image_lib.php
on line 1157
But when i uploaded this same project on my companies server everything is working fine, no problem in image resize for big images also.
I didn't understand why this happens with client's server. I am unable to find difference between these two server.
Client's server phpinfo:-
PHP Core
Directive Local Value Master Value
allow_call_time_pass_reference On On
allow_url_fopen On On
allow_url_include Off Off
always_populate_raw_post_data Off Off
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_globals_jit On On
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_classes no value no value
disable_functions no value no value
display_errors STDOUT STDOUT
display_startup_errors Off Off
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting no value no value
expose_php On On
extension_dir /usr/local/php5/lib/php/extensions /usr/local/php5/lib/php/extensions
file_uploads On On
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path .:/usr/local/php5/lib/php .:/usr/local/php5/lib/php
log_errors Off Off
log_errors_max_len 1024 1024
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
mail.force_extra_parameters no value no value
max_execution_time 30 30
max_file_uploads 20 20
max_input_nesting_level 64 64
max_input_time -1 -1
memory_limit 500M 500M
open_basedir no value no value
output_buffering 0 0
output_handler no value no value
post_max_size 8M 8M
precision 14 14
realpath_cache_size 16K 16K
realpath_cache_ttl 120 120
register_argc_argv On On
register_globals Off Off
register_long_arrays On On
report_memleaks On On
report_zend_debug On On
safe_mode Off Off
safe_mode_exec_dir /usr/local/php/bin /usr/local/php/bin
safe_mode_gid Off Off
safe_mode_include_dir no value no value
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
serialize_precision 100 100
short_open_tag On On
SMTP localhost localhost
smtp_port 25 25
sql.safe_mode Off Off
track_errors Off Off
unserialize_callback_func no value no value
upload_max_filesize 8M 8M
upload_tmp_dir no value no value
user_dir no value no value
variables_order EGPCS EGPCS
xmlrpc_error_number 0 0
xmlrpc_errors Off Off
y2k_compliance On On
zend.ze1_compatibility_mode Off Off

phpinfo where my code is working properly:-
PHP Core
Directive Local Value Master Value
allow_call_time_pass_reference On On
allow_url_fopen On On
allow_url_include Off Off
always_populate_raw_post_data Off Off
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_globals_jit On On
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_classes no value no value
disable_functions no value no value
display_errors STDOUT STDOUT
display_startup_errors Off Off
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl On On
error_append_string no value no value
error_log error_log error_log
error_prepend_string no value no value
error_reporting 6135 6135
expose_php On On
extension_dir /usr/local/lib/php/extensions/no-debug-non-zts-20060613 /usr/local/lib/php/extensions/no-debug-non-zts-20060613
file_uploads On On
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path .:/usr/lib/php:/usr/local/lib/php .:/usr/lib/php:/usr/local/lib/php
log_errors On On
log_errors_max_len 1024 1024
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
mail.force_extra_parameters no value no value
max_execution_time 30 30
max_file_uploads 20 20
max_input_nesting_level 64 64
max_input_time 60
#9

[eluser]ashwini[/eluser]
whether upload_max_filesize affect?But my client rejected this answer and i don't have access to change anything. I have to give exact reason to my sir .... anybody help me.




Theme © iAndrew 2016 - Forum software by © MyBB