Welcome Guest, Not a member yet? Register   Sign In
Getting uploadify to work
#71

[eluser]RKC[/eluser]
Hi pickupman!

Thanks for the script and thanks for replying.

The moment I remove the comma. The input field disappears from browser. And when I check the source, I see no problem with the input field html. It reads:

<input type="file" name="Filedata" value="" id="upload" />

But there is no input field displayed on the browser. However, all this while, it works perfectly in firefox. It is only IE that is giving problems.

Thanks again.

RKC
#72

[eluser]pickupman[/eluser]
@RKC
I checked the demo files again. I tried it in IE6, and it was working. I attached them here again, and updated it from my site again.
#73

[eluser]Unknown[/eluser]
Hi there,

I have discovered some issue, when implementing uploadify into Zend Framework. My Code:

uploadify.js (mainly from examples)
Code:
$(document).ready(function() {
    $("#fileUploadgrowl").fileUpload({
        'uploader': BASE_URL + '/public/flash/uploader.swf',
        'cancelImg': BASE_URL + '/public/images/uploadify/cancel.png',
        'script': BASE_URL + '/file/upload/',
        'folder': '/public/photos/albums/' + ALBUM,
        'fileDesc': 'Photos',
        'fileExt': '*.jpg;*.jpeg;*.png;*.gif',
        'multi': true,
        'simUploadLimit': 1,
        'sizeLimit': 1048576,
        'buttonText' : 'Browse',
        
        ...
    });
});

BASE_URL contains current project location starts with 'http://'

Everything works good as long as this script try to find upload script on address BASE_URL + '/albums/test/http:' (BASE_URL + '/albums/test/' is page, where is uploader GUI).

Manual sais: "For absolute paths prefix the path with either ‘/’ or ‘http’", but for some reason not work good for me. Any suggestions?
#74

[eluser]thematrixuum[/eluser]
Code:
$("#target").append(info);  //Add response returned by controller

what does this means?
#75

[eluser]pickupman[/eluser]
[quote author="thematrixuum" date="1259851964"]
Code:
$("#target").append(info);  //Add response returned by controller

what does this means?[/quote]
This is basic jQuery stuff. $("#target") specifies an html element with and id of target (ie <div id="target"></div>. Since this is called from function(info){},.append(info) means take what was echoed back by the script, and store it in the variable "info". Then append (add) to the inside of the referenced html element, which what the <div> with the id "target".

http://docs.jquery.com/Manipulation/append#content
#76

[eluser]thematrixuum[/eluser]
oh, it was supposed to return the value from the filename, filesize etc into the <div id='target'>? but how can i send the filename back into the controller? issit inside $.post()? everytime i try to save the filename into the database, it said that it was an [Object object] and cannot be saved although i already json_encode it..
#77

[eluser]pickupman[/eluser]
I just had it echo back the sample data processed by the uploadify.php script. It's up to you how you would like to process this in the controller. The code above the line:
Code:
$.post("'.site_url(upload/uploadify).'", { filearray : response },function(html){

the script is passing a json object "response" as a $_POST variable "filearray" and posted to the Upload controller function uploadify. The data can be retrieved by:

Code:
//application/controllers/upload.php
$data['response'] = json_decode($this->input->post('filearray'));

//Access data using php json object
$data['file_name'] = $data['response']->file_name;
$data['file_size'] = $data['response']->file_size;
$data['file_type'] = $data['response']->file_type;
$data['file_ext'] = $data['response']->file_ext;

//Do whatever else you would like ie. save path to DB/create thumb

print_r($data);
Now whatever you echo out is stored in the javascript variable "html", and will be appended to the <div id="target">
#78

[eluser]thematrixuum[/eluser]
woah.. thanks a mil.. some additional questions (i am not very good in javascript btw)

1. what if i want to return '1' back to the javascript so that the javascript will redirect?
2. where can i do validation, eg : if the file was already in the server or if the file is corrupt / cannot be uploaded?
3. last but not least, how can i set that whenever a user wanted to upload a file, he / she can only see the mime type that was set?

thanks a mil.

added : btw, when I do this :
controller/upload.php
Code:
$data['response'] = json_decode(stripslashes(trim($this->input->post('filearray'))));

                //Access data using php json object
                $data['file_name'] = $data['response']->file_name;
                $data['file_size'] = $data['response']->file_size;
                $data['file_type'] = $data['response']->file_type;
                $data['file_ext'] = $data['response']->file_ext;
                
                print_r($data);
view/uploadFile.php
Code:
$(document).ready(function(){
                    $("#upload").uploadify({
                            uploader: '&lt;?php echo base_url();?&gt;assets/uploadify/uploadify.swf',
                            script: '&lt;?php echo base_url();?&gt;assets/uploadify/uploadify.php',
                            cancelImg: '&lt;?php echo base_url();?&gt;assets/uploadify/cancel.png',
                            folder: '../../assets/upload',
                            scriptAccess: 'always',
                            multi: false,
                            '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);
                            },
                            'onComplete' : function (event, queueID, fileObj, response, data) {
                                $.post('&lt;?php echo site_url('asset/uploadify');?&gt;', {filearray: response}, onCompletePost(data),"json");
                                
                                
                                
                            }
                    });
            
                    function onCompletePost(data) {
                            alert(data);
                    }
        });

it still returned as an alert with [Object object]
#79

[eluser]pickupman[/eluser]
By adding ,json to the $.post callback type, you are telling the script to expect json, but right now the script is only returning plain text. Try removing the ,json after your callback.

Quote:1. what if i want to return ‘1’ back to the javascript so that the javascript will redirect?

Rather than
Code:
print_r($data);

use:

Code:
echo 1;

Quote:2. where can i do validation, eg : if the file was already in the server or if the file is corrupt / cannot be uploaded?

This is already somewhat handled by uploadify. I added the CI upload functions into the uploadify script. So, if the file already exists (file.jpg), the file be renamed to file-1.jpg. If the file is not properly uploaded, the onError callback will fire. Right now, an alert is fired back with code.
Code:
//Original file name is stored in
$data['response']->real_name;

//Check if file already there
if($data['response']->file_name != $data['response']->real_name;)
     //Do something because file was renamed since it already exists.

Quote:3. last but not least, how can i set that whenever a user wanted to upload a file, he / she can only see the mime type that was set?

You could try this:
Code:
$this->load->helper('file');

//Make sure you have your file extensions set in your /config/mimes.php
$data['mime'] = get_mime_by_extension($data['response']->file_ext);
echo $data['mime'];
#80

[eluser]vijaykm[/eluser]
hi i have problem in IE 7 while uploading files ..all the session values are destroyed




Theme © iAndrew 2016 - Forum software by © MyBB