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

[eluser]Puspex[/eluser]
Hummm...is the json returning something?
Try to echo the data sent back from json!
#62

[eluser]Adrian Walls[/eluser]
It doesn't even appear to be getting that far as any echo statement I try in the uploadify.php file is not being output.

It's really baffling me and I know it's going to turn out to be something simple in the end.
#63

[eluser]pickupman[/eluser]
You probably won't have anything outputted via uploadify.php, unless you are viewing using firebug. It's sent via flash/javascript. As it's been pointed out in earlier threads, make sure you have added "application/octet-stream" to each filetype in your config/mimes.php file.

Check if this is in your uploadify js options object:
Code:
'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);
                        },
This callback function helped me figure out I had the wrong write permissions on my upload folder.
#64

[eluser]Adrian Walls[/eluser]
Thanks for all the replies. Think I am starting to set somewhere, though still having one or two issues. I came across this tutorial

http://www.reloadedpc.com/code-igniter/j...deigniter/

I have implemented it and now the file is actually being uploaded to the upload dir. However the JSON returned shows:

Code:
C:/Sites/dev{"file_name":"S73F1070.JPG","real_name":"S73F1070.JPG","file_ext":".JPG","file_size":621.05,"file_path":"C:\/Sites\/dev\/cleonard\/uploads\/S73F1070.JPG","file_temp":"C:\\WINDOWS\\Temp\\php9F.tmp"}

You will see that for some reason it has stuck "C:/Sites/dev" in front of the opening brace and therefore this is obviously breaking the JSON when I want to get the file name. Anyone come across this before?
#65

[eluser]pickupman[/eluser]
Glad to see my tutorial from my site help. It took me awhile to get going, that's why I tried to put together a clean controller to demo it on. I can't think where the "C:\sites\dev" would be coming from. I read through the code quick, and didn't see any echo placed anywhere that would be appending itself to the front of that string.
What if your create an array by hand and echo the json.
Code:
$test = array('fruit'=>'bannana','vegetable'=>'tomato');

$json = json_encode($test);
echo $json;
#66

[eluser]eoinmcg[/eluser]
Hi Wallzy,

As I recall, when I implemented uploadify, I noticed it was adding a lot of stuff onto $_REQUEST['folder']

Cleaning it up did the trick
#67

[eluser]Unknown[/eluser]
Hi everybody,

Just to know if it's possible to have the filepath i want to upload. I'm working with a script in VB.NET. I'm using this :

'onComplete': function(event, queueID, fileObj, response, data)
{
tableaufichier = tableaufichier + fileObj["filepath"] + "/" + fileObj["name"] + ";";
},

but the result is already [undefined]+filename.

regards,
#68

[eluser]Adrian Walls[/eluser]
Hi Guys,

I tried hand crafting the array and it returns what you would expect:

Code:
{"fruit":"bannana","vegetable":"tomato"}

The issue obviously lies the the uploadify.php

Code:
if (!empty($_FILES)) {    
   $path = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
   //$client_id = $_GET['client_id'];
   $file_temp = $_FILES['Filedata']['tmp_name'];
   $file_name = prep_filename($_FILES['Filedata']['name']);
   $file_ext = get_extension($_FILES['Filedata']['name']);
   $real_name = $file_name;
   $newf_name = set_filename($path, $file_name, $file_ext);
   $file_size = round($_FILES['Filedata']['size']/1024, 2);
   $file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES['Filedata']['type']);
   $file_type = strtolower($file_type);
   $targetFile =  str_replace('//','/',$path) . $newf_name;
   move_uploaded_file($file_temp,$targetFile);

   $filearray = array();
   $filearray['file_name'] = $newf_name;
   $filearray['real_name'] = $real_name;
   $filearray['file_ext'] = $file_ext;
   $filearray['file_size'] = $file_size;
   $filearray['file_path'] = $targetFile;
   $filearray['file_temp'] = $file_temp;
   //$filearray['client_id'] = $client_id;
   $json_array = json_encode($filearray);
   echo $json_array;
}else{
    echo "1";    
}

However I can't find out what these values are? Is there way to debug this?
#69

[eluser]RKC[/eluser]
Hi,

Thanks for posting the link: http://www.reloadedpc.com/code-igniter/j...deigniter/

I could get uploadify working in Firefox but IE 6 is giving problems. I get the error:

"document.getElementById is null or not an object."

Did anyone else face this problem with IE. I have been searching google for the past 3-4 hours but still no luck as to the solution to this problem.

Thanks again.

RKC
#70

[eluser]pickupman[/eluser]
@RKC
Quote:I could get uploadify working in Firefox but IE 6 is giving problems. I get the error:

“document.getElementById is null or not an object.

I noticed in my zip file, I had an extra comma in the js options object

In /views/upload/view.php line 31
Code:
'onComplete'   : function (event, queueID, fileObj, response, data) {
                                                //Post response back to controller
                                                $.post('<?php echo site_url('upload/uploadify');?>',{filearray: response},function(info){
                                                    $("#target").append(info);  //Add response returned by controller                                                                          
                                                });                                            
                            },

Change to
Code:
'onComplete'   : function (event, queueID, fileObj, response, data) {
                                                //Post response back to controller
                                                $.post('<?php echo site_url('upload/uploadify');?>',{filearray: response},function(info){
                                                    $("#target").append(info);  //Add response returned by controller                                                                          
                                                });                                            
                            }




Theme © iAndrew 2016 - Forum software by © MyBB