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

[eluser]Unknown[/eluser]
hey guys I implemented it using coldfusion, I got it to work but when i upload large images over a meg then if there are 10 or more files in que it gives me the IO error. The interesting part is that I get the IO error before it even tried uploading to the server.

Any ideas on how to resolve it? You can view it at http://isajha.com/float
#22

[eluser]merqlove[/eluser]
Hi guys!

My solution is:

Replace code in the .fla file at line 349, between:

Code:
if (param.script.substr(0,1) != '/') param.script = param.pagepath + param.script;
REPLACE
file.upload(scriptURL, param.fileDataName);

REPLACE

Code:
var scriptURL:URLRequest = new URLRequest(param.script);
scriptURL.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.folder = getFolderPath();
variables.scriptdata = param.scriptData;
scriptURL.contentType = 'multipart/form-data';
scriptURL.data = variables;

RESULT:

Code:
if (param.script.substr(0,1) != '/') param.script = param.pagepath + param.script;
var scriptURL:URLRequest = new URLRequest(param.script);
scriptURL.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.folder = getFolderPath();
variables.scriptdata = param.scriptData;
scriptURL.contentType = 'multipart/form-data';
scriptURL.data = variables;
file.upload(scriptURL, param.fileDataName);

Now i using CI standard Upload library with disabled file_type checking.
Uploading is true work. I saw uploaded files.

UPD.
Growl too work. Just cleaned 'path' var from Growl onComplete.
Because i have 1 folder with subfolders by file types.

UPD.

I have changed Upload class for check via extensions.
Because server return type of any file as "application/octet-stream" because we are using flash for upload.

Cheers, Alex
#23

[eluser]jaargo[/eluser]
Can someone maybe post an example because I can't get it to work! Get successmessage but no files are uploaded. Sad
#24

[eluser]merqlove[/eluser]
[quote author="jaargo" date="1247148499"]Can someone maybe post an example because I can't get it to work! Get successmessage but no files are uploaded. Sad[/quote]

jaargo, my swf working with the POST method. Replace in upload.php (or your own CI uploader) $_GET with $_POST.
#25

[eluser]jaargo[/eluser]
[quote author="merqlove" date="1247166243"][quote author="jaargo" date="1247148499"]Can someone maybe post an example because I can't get it to work! Get successmessage but no files are uploaded. Sad[/quote]

jaargo, my swf working with the POST method. Replace in upload.php (or your own CI uploader) $_GET with $_POST.[/quote]

Really?

I did a crappysolution now when linking to uploadify outside CIdir, with a querystring with the galleryid (im doing a imagecms with different galleries)

But ill give yours a try again!

Do I just switch to your swf and then it'll work? With upload.php in the controller aswell?

**edit**

Do i need to mention that i'm a newbie at this? Wink
#26

[eluser]jaargo[/eluser]
Could you please post your view and controller file plz?


It works with your swf outside CI, but when I call it from inside the viewfile i get the IO - Error...
#27

[eluser]merqlove[/eluser]
[quote author="jaargo" date="1247174740"]Could you please post your view and controller file plz?


It works with your swf outside CI, but when I call it from inside the viewfile i get the IO - Error...[/quote]

Yep
My controller path is: /somefolder/uploader

Code:
<?php
if (!defined('BASEPATH')) exit ('No direct script access allowed');

class Uploader extends Controller
{
    function Uploader()
    {
        parent::Controller();
        $this->load->library('json'); //it's only for me, because my server don't have json_encode()
    }

    function index()
    {
        if (! empty($_FILES))
        {

            $config['upload_path'] = '..'.$_POST['folder']; // path to the upload dir
            $config['allowed_types'] = 'tmp,html'; // my file type checking only via uploadify (because i changed Upload library, for file checking by extension)
            $config['max_size'] = '1000000'; // max file size
            //log_message('error', $_FILES['userfile']['tmp_name'] . " | " . $config['upload_path'] . " | " . $_FILES['userfile']['name']);
            //it's for debug, you can try it. just turn on error logs for level 1 in application/config/config.php
            $this->load->library('upload', $config);


            if (!$this->upload->do_upload())
            {// error message
                $error = $this->upload->display_errors();
                $json_array = $this->json->json_encode($error);
                echo $json_array;
                return;
            }
            else
            {// output data
                $data = $this->upload->data();
                $json_array = $this->json->json_encode($data);
                echo $json_array;
                //  log_message('error', print_r($data, TRUE)); // second debug example
                return;
            }


        }
        echo 1;

    }
}

So you can put to Uploadify true path (as in your site).

FOR EXAMPLE

Quote:If your controller path at your site is: http://mysite.com/my_controller

Then your script path in uploadify is:
/my_controller

Same with upload folder.

Quote:If your folder path: http://mysite.com/upload

Then your folder path in uploadify is:
/upload

p.s.

Quote:You need to use easy script (like uploadify), because upload library don't understand flash application/octet-stream mime.

So, look to my settings.
#28

[eluser]jaargo[/eluser]
Hmm... I'm close now!

The connection is done but I get strange errorlogs:

does the script add to the folderpath i precise?

in script:

Code:
'folder': 'galleries',

Code:
in log: /galleries/root/admin/index.php/upload/galleries

it adds the 'root/admin/index.php/upload/galleries' part somewhere.


But when i hardcode the path in the script it passas that stage but fails at:

ERROR - 2009-07-10 12:45:44 --> /tmp/php1rHBm2 | ./pictures | DSC01718.JPG
ERROR - 2009-07-10 12:45:44 --> You have not specified any allowed file types.

but i have:
Code:
$config['allowed_types'] = 'gif|jpg|jpeg|png';
#29

[eluser]jaargo[/eluser]
hmm I guess its the application/octet-stream mime. thats bringing it down now?

Or do I get the whole thing wrong? CI can't get the file_ext from flash? Tongue Don't I lose the whole uploadigy-smootheness if I can't use flash?

How did you change the uploadclass?

Lot's of questions going on here.. But hey, I'm learning! =) Thx a million for your help guys!
#30

[eluser]merqlove[/eluser]
Jargo, Yep.

M_K made good solution,

Open up uploadify.js (un-compressed version), and made a few changes between lines 60 and 85:
Code:
if (flashVer >= 9) {
                    $(this).each(function(){
                        settings = $.extend({
                        uploader:      'uploader.swf',
                        script:        'upload.php',
                        folder:        '',
                        height:        30,
                        width:         110,
                        cancelImg:     'cancel.png',
                        wmode:         'opaque',
                        scriptAccess:  'sameDomain',
                        fileDataName:  'Filedata',
                        displayData:   'percentage',
                        onInit:        function() {},
                        onSelect:      function() {},
                        onCheck:       function() {},
                        onCancel:      function() {},
                        onError:       function() {},
                        onProgress:    function() {},
                        onComplete:    function() {}
                    }, options);
                    var pagePath = location.pathname;
                    pagePath = pagePath.split('/');
                    pagePath.pop();
                    pagePath = pagePath.join('/') + '/';
                    var data = '&pagepath;=' + '';

After changes in uploadify js, try more easiest controller method:

Code:
<?php if (!defined('BASEPATH')) exit ('No direct script access allowed');

class Uploader extends Controller
{
    function Uploader()
    {
        parent::Controller();
    }

    function index()
    {
        // JQuery File Upload Plugin v1.4.1 by RonnieSan - (C)2009 Ronnie Garcia
        if (!empty($_FILES)) {
            $tempFile = $_FILES['Filedata']['tmp_name'];
            $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_POST['folder'] . '/';
            $targetFile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
            log_message('error', $tempFile . " | " . $targetPath . " | " . $targetFile);
            
            // Uncomment the following line if you want to make the directory if it doesn't exist
            // mkdir(str_replace('//','/',$targetPath), 0755, true);
            
            move_uploaded_file($tempFile,$targetFile);
        }
        
        echo '1';
    }
}

?>

and change folder to:

Code:
'folder': '/galleries',

And add

Sorry, now changed Upload library very specified for my needs, without comments or help.

Cheers, Alex




Theme © iAndrew 2016 - Forum software by © MyBB