It looks like you're new here. If you want to get involved, click one of these buttons!
Bramme said:Could you post the full js file for this? I'm having trouble getting Uploadify to work with CI too.
// After: (line 62)
settings = $.extend({
// Add:
pagePad: location.pathname,
// change this
var pagePath = location.pathname;
// Into this
var pagePath = settings.pagePad;
$(this).each(function(){
settings = $.extend({
pagePad: location.pathname,
uploader: 'uploader.swf',
script: 'uploader.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 = settings.pagePad;
pagePath = pagePath.split('/');
pagePath.pop();
pagePath = pagePath.join('/') + '/';
function upload() {
$client_id = $this->Sql->getClientUserClientId($user_id);
$uploadify = <<<JS
<script type=\"text/javascript\">
$(document).ready(function() { // wait for document to load
$('#claimfile').fileUpload({
'uploader' : '/js/uploader.swf',
'script' : '/uploadify/upload.php',
'scriptData' : {'client_id':'
JS;
$uploadify.= $client_id;
$uploadify.= <<<JS2
'},
'scriptAccess' : 'sameDomain',
'multi' : true,
'fileDataName' : 'claimfile',
'cancelImg' : '/images/icon-delete.gif',
'auto' : true,
'folder' : '/files',
'fileExt' : '*.txt;*.rtf;*.doc;*.docx;*.pdf;*.mp3;*.wav;*.aif;*.wp5;*.wpd;*.jpg;*.png;*.zip',
'fileDesc' : 'Select files of type .txt, .rtf, .doc, .pdf, .mp3, .wav, .aif, or .zip',
'sizeLimit' : '3072000',
'simUploadLimit': '8',
'onError' : function (a, b, c, d) {
if (d.status == 404)
alert('Could not find upload script. Use a path relative to: '+'<?= getcwd() ?>');
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(\"/dashboard/uploadify\", { 'filearray' : response });
},
'onAllComplete': function(event, data) {
alert(\"Uploading Complete!\\nTotal uploaded: \"+data.filesUploaded+\"\\nTotal errors: \"+data.errors+\"\\nClose this box to refresh the page and see your uploaded files.\");
$.post(\"/dashboard/uploadify_notify\", { 'client_id':'
JS2;
$uploadify.= $client_id;
$uploadify.= <<<JS3
','notify_type':'uploaded' });
window.location.href=\"/dashboard\";
}
});
$(\"tr:odd\").addClass(\"odd\");
});
</script>
JS3;
$x['scripts'][] = $uploadify;
$this->load->view('uploads_v');
}
function uploadify() {
$file_array = array();
$farray = $_POST['filearray']; // the json array from /uploadify/upload.php
$farray = str_replace('{','',$farray); // get rid of curly brackets
$farray = str_replace('}','',$farray);
$farray = trim($farray); // get rid of any extra white space
$fparts = explode(\", \",$farray); // turn it back into a PHP array
foreach ($fparts as $fp) {
$key = strtok($fp, \": \");
$key = str_replace(\"'\",'',$key);
$val = strtok(\": \");
$val = str_replace(\"'\",'',$val);
$file_array[$key] = $val;
}
$this->Sql->insertFile($file_array); // save it to the db
}
function uploadify_notify() {
$client_id = $_POST['client_id']; // get the client ID from the Jquery script above
$notify_type = $_POST['notify_type']; // there are various notification types - only relevant to my purposes but included for what it's worth
$this->send_notification($client_id,$notify_type); // sends the notification thru CI's Email class in another function.
}
'script' : '<?php echo base_url(); ?> uploadify/uploadify.php',
'folder' : '/MyProject/uploads','onComplete' : function(event,fileObj,data,response)echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);/MyProject/uploads/akhil.jpg'onComplete' : function(event,fileObj,data,response)
{
alert(response);
$.ajax({
url: "controller_url",
type:"POST",
data:"file_path="+response,
success: function(html)
{
alert(html);
},
error: function(html)
{
alert(html);
}
});//ajax over
},$_SERVER['DOCUMENT_ROOT'].$this->input->post('file_path')