I am a newbie to CodeIgniter. I tried to use flexpaper in my CodeIgniter code using my PHP knowledge in the view area alone, and it doen't seem to be working. It stops with document loading....
I am trying to display already converted documents. My actual problem is this: in the below JavaScript code which is in the view area of my CI, addresses a location in the line SwfFile : escape(base) in the below code; now where should the folder which contains the swf files be placed?
var doc = '<?php print $doc; ?>';
var doc1 = '<?php print $doc1; ?>';
var base = 'swf/'+'<?php print $doc1; ?>';
var fp = new FlexPaperViewer(
'FlexPaperViewer',
'viewerPlaceHolder', { config : {
SwfFile : escape(base),
Scale : 0.6,
ZoomTransition : 'easeOut',
ZoomTime : 0.5,
ZoomInterval : 0.2,
FitPageOnLoad : true,
FitWidthOnLoad : true,
PrintEnabled : true,
FullScreenAsMaxWindow : false,
ProgressiveLoading : false,
MinZoomSize : 0.2,
MaxZoomSize : 5,
SearchMatchAll : false,
InitViewMode : 'Portrait',
ViewModeToolsVisible : true,
ZoomToolsVisible : true,
NavToolsVisible : true,
CursorToolsVisible : true,
SearchToolsVisible : true,
localeChain: 'en_US'
}});
I think flash files in CI have to be in the root of the application to work.
To load your view files, you need to call:
$this->load->view('yourViewFile');
where in the view folder, the file name would be yourViewFile.php
In case if you haven't changed much in your codeigniter since after you downloaded it, this controller name should be welcome.php under application/controllers, and you can write the above code in your index() function!
Related
I'm building a site (in php) that uses uploadify to allow a user to upload portfolio images.
I have uploadify working fine, but I'm just wondering the best way of showing the uploaded images on the page once they have been uploaded. Is it possible to do without a page refresh?
I've pasted my uploadify code below:
<script>
<?php $timestamp = time();?>
var counter = 1;
$(function() {
$('#file_upload').uploadifive({
onUploadComplete: function(event, queueID, fileObj, reponse, data) {
//alert(counter);
counter = counter +1 ;
},
'buttonText' : 'Upload Images...',
'uploadLimit' : 12,
'uploadScript' : '/includes/uploadifive.php',
'checkScript' : '/includes/check-exists.php',
'auto' : true,
'method' : 'post',
formData : {
'page_id' : '<? echo $pageDetails->row['page_id'] ?>',
'counter' : counter,
'timestamp' : '<? echo $timestamp;?>',
'token' : '<? echo md5('unique_salt' . $timestamp);?>'
},
});
});
</script>
I'm not too sure how to get the file name from uploadify
Sure, you can just add img elements to the page dynamically via the DOM:
var img = document.createElement('img');
img.src = "/path/to/the/new/img.png";
document.getElementById("somecontainer").appendChild(img);
Live Example | Source
You may need to do an ajax call to the server to get the path of the new image, unless that falls out naturally from your application logic.
In the edition I use there is a function
onUploadSuccess : function(file,data,response){
}
Then I can get file name by file.name;
So in your code maybe the fileObj, You can try fileObj.name to get the name of the file you upload.
i'm trying to show some data via dataview, but for some reason i am getting an emptytext message (No data).
Here is my dataview:
xtype : 'dataview',
emptyText : 'No data',
id : 'cartdata',
multiSelect : true,
plugins : new Ext.DataView.DragSelector( { dragSafe : true } ),
store : new Ext.data.JsonStore({
url : '/aecms/user-photos-view/',
autoLoad : true,
root : 'data',
fields : [
'images'
],
listeners : {
scope : this,
load : function(store) {
var data = store.reader.jsonData;
if (data.systemMessage) {
infoReport(data.systemMessage.title, data.systemMessage.message, data.systemMessage.icon);
}
}
}
}),
tpl : new Ext.XTemplate(
'<tpl for=".">',
'<tpl for="images">',
'<a title="{id}">test</a>',
'</tpl>',
'</tpl>'
)
and this is a data from php:
{"data":{"images":{"id":"2"}},"status":"success"}
I am new to extjs and appreciate any help.
By the looks of it you are not returning a successProperty value correctly. Change the response from you php code to be, as listed below.
The default successProperty of the JsonReader on your store is 'success'. ExtJs will look for this property in your server response.
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.JsonReader-cfg-successProperty
Also, you will probably want to return your data as a json array, not an object. You dont need the image object inside the data array.
Server response:
{ "data":[{"id":"2"}], "success":true }
Javascript:
...
store : new Ext.data.JsonStore({
url : '/aecms/user-photos-view/',
autoLoad : true,
root : 'data',
fields : [
'id'
],
listeners : {
scope : this,
load : function(store) {
var data = store.reader.jsonData;
if (data.systemMessage) {
infoReport(data.systemMessage.title, data.systemMessage.message, data.systemMessage.icon);
}
}
}
})
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<a title="{id}">test</a>',
'</tpl>'
)
i have been trying so hard to fix my issue. I've looked on google loads and attempted the fixes but i am having no luck at all.
$(function() {
$("#listing_pic").uploadify({
height : 30,
swf : 'uploadify/uploadify.swf',
uploader : 'uploadify/uploadify.php',
width : 120,
fileExt : '*.jpg; *.jpeg; *.JPG; *.JPEG;',
checkExisting : 'uploadify/check-exists.php',
simUploadLimit: 2,
fileSizeLimit : '4MB',
auto : true,
multi : true,
onComplete : function(event,queueID,fileObj,response,data) {
$('#hiddenlistingpic').val(response);
},
});
});
Im trying to get Uploadify to upload my image to my server (which works fine) but then send the filename to the hidden field so that i can post the data into my database update class. It's giving me a headache, and im more than certain its a simple fix.
from here: https://stackoverflow.com/a/3466188/1253747
$(function() {
$("#listing_pic").uploadify({
height : 30,
swf : 'uploadify/uploadify.swf',
uploader : 'uploadify/uploadify.php',
width : 120,
fileExt : '*.jpg; *.jpeg; *.JPG; *.JPEG;',
checkExisting : 'uploadify/check-exists.php',
simUploadLimit: 2,
fileSizeLimit : '4MB',
auto : true,
multi : true,
onComplete : function(event,queueID,fileObj,response,data) {
$('#hiddenlistingpic').val(fileObj.name);
},
});
});
or from the uploadify docs, there seems to be many other ways to get it:
'onUploadSuccess' : function(file, data, response) {
$('#hiddenlistingpic').val(file.name);
}
same thing can be done with the onuploadcomplete.
or is there anything else that i am missing?
Through an ExtJs form I am uploading a file for processing in php (csv file in this matter).
The processing all works fine without errors or anything. And as far as I know, all of the other requirement for a proper response are met.
Return message = {success: true}
Response header Content/Type = text/html
Status = 200 OK
However ExtJs keeps showing my WaitMsg instead of going to my success of failure functions
Here is my form:
var form = new Ext.FormPanel({
id : 'mailinglist_form_import',
labelWidth : 210,
fileUpload : true,
border : false,
url : '/plugin/NewsletterManagement/mailinglist/import',
items : [{
xtype : 'fieldset',
width : 560,
border : false,
autoHeight : true,
labelWidth : 215,
defaultType : 'textfield',
defaults : {
width : 307,
labelStyle : 'font-weight: bold;'
},
items : [{
fieldLabel : t('Name') + ' *',
name : 'mli_name',
allowBlank : false
},{
xtype : 'textfield',
fieldLabel : t('File') + ' *',
name : 'file',
inputType : 'file'
}]
}]
});
The button:
var saveBtn = new Ext.Button({
text: t("Save"),
iconCls: 'pimcore_icon_save',
handler: function() {
form.getForm().submit({
waitMsg: t('Saving...'),
success: function () {
var tabpanel = Ext.getCmp("pimcore_panel_tabs");
Ext.MessageBox.alert (t('Message'),t('Data has been saved'));
form.getForm().reset();
grid.getStore().reload();
tabpanel.activate(gridTabId);
tabpanel.remove(tabId);
},
failure: function () {
Ext.MessageBox.alert (t('Message'),t('Saving data failed'));
}
});
}
});
The PHP file contains an echo:
echo "{'success': true}";
Any help is greatly appriciated.
Greetz,
XpertEase
Open console and see the error. If you dont's see both of your alerts -- then it's some error in code, in extjs side. Understand it, fix and then report back.
<script type="text/javascript">
$(document).ready(function() {
$("#uploadify").uploadify({
'uploader' : 'scripts/uploadify.swf',
'script' : 'scripts/uploadify.php',
'buttonImg' : 'css/btn_browseFiles.png',
'rollover' : 'true',
'wmode' : 'transparent',
'height' : '26px',
'width' : '109px',
'cancelImg' : 'cancel.png',
'folder' : 'uploads',
'queueID' : 'fileQueue',
'simUploadLimit' : '2',
'auto' : true,
'multi' : true,
'onComplete' : function(event, queueID, fileObj, response, data) {
$('#filesUploaded').append('<li><strong>file:</strong> '+fileName+'</li>');
}
});
});
</script>
I want to get the "+fileName+" to echo in PHP so I can pass it in a contact form.
<?php $que = ""; ?>` fill in the blanks
<input type="hidden" name="" value="<?php echo($que); ?>">
Besides doing the following, I don't know of a way to pass Javascript variables to PHP...
<script type="text/javascript>
location.href="thisPage.php?fileName=" + fileName;
</script>
And then you would use PHP to do:
<?PHP $que = $_GET["fileName"]; ?>
If you want to use the text in the filename variable, you will need to pass it to a server request somehow.
It can be done several ways:
cookie
getline variable/query string
post variable (put it in a form element)
If you just want to get it into a value on the current page, you should be able to use javascript to do it:
#('#id_of_element').val(filename);
This is assuming you are using jQuery.
This looks like some sort of uploading flash component. If it is uploading the file to your server, then you should be able to intercept the request and work with it from there.
$trigger('uploadifyComplete',ID,{
'name' : event.currentTarget.name,
'filePath' : getFolderPath() + '/' + event.currentTarget.name,
'size' : event.currentTarget.size,
'creationDate' : event.currentTarget.creationDate,
'modificationDate' : event.currentTarget.modificationDate,
'type' : event.currentTarget.type
},
can you see these?so you can use fileObj.name to get file name.