I have flash file that sends file to php but I cannot debug it. e.g. var_dump($_FILE) shows nothing! However when I run script it does work and upload file to server.
This is part of action script.
listener.onSelect = function (selectedFile, bytesTotal) {
browse._visible = false;
uploadBtn._visible = true;
var _loc3 = new Date();
sendTimeFLASH = _loc3.getTime();
sendTime = sendTimeFLASH;
totalId = flashimgID + ":" + selectedFile.name;
flash.external.ExternalInterface.call("funName", totalId);
statusArea.text = details.text = "";
txt_mc.statusArea.text = txt_mc.statusArea.text + selectedFile.name;
videoFile_name = selectedFile.name;
var _loc4 = imageFile.size;
d = _loc4 / 1000;
txt.text = selectedFile.name + "(" + Math.round(d) + "Kb): now click Upload to proceed";
var _loc1 = new LoadVars();
_loc1.imgPHP = flashimgID;
_loc1.imgName = selectedFile.name;
_loc1.timePHP = sendTime;
_loc1.sendAndLoad("page.php", _loc1, "POST");
imageFile.upload("page.php?id=" + flashimgID);
};
file is not sent in $_FILES from flash, but as a byte array.
save it like this:
$data = file('php://stdin');
if(file_put_contents('/path/to/file',$data)){
echo 1;
}else{
echo 0;
}
Related
This is my QDataGrid
$this->content = new QDataGrid($this, 'Dashboard');
$this->dtgContent->UseAjax = true;
$this->dtgContent->ShowFilter = true;
$this->dtgContent->RowActionParameterHtml = '<?= $_ITEM->FileNum ?>';
$this->dtgContent->SetDataBinder('BindDataGrid_Content', $this);
$this->dtgContent->Paginator = new QPaginator($this->dtgContent);
$this->dtgContent->ItemsPerPage = 15;
$this->dtgContent->SortColumnIndex = 5;
$this->dtgContent->SortDirection = true;
Then i am creating 2 QDataGridColumns
$col = new QDataGridColumn('First', '<?= $_CONTROL->ParentControl->renderFirst($_ITEM) ?>');
$col->HtmlEntities = false;
$col->OrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin);
$col->ReverseOrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin, false);
$col->Filter = QQ::Like(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin, null);
$col->FilterType = QFilterType::TextFilter;
$col->FilterPrefix = $col->FilterPostfix = '%';
$col->Width = 170;
$this->dtgContent->AddColumn($col);
$col = new QDataGridColumn('Year', '<?= $_ITEM->CfgfilevehicleAsFileNum->VehicleIdObject->Year ?>');
$col->FilterType = QFilterType::TextFilter;
$col->Filter = QQ::Like(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Year, null);
$col->FilterPostfix = $col->FilterPrefix = '%';
$col->OrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Year);
$col->ReverseOrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Year, false);
$col->Width = 50;
$this->dtgContent->AddColumn($col);
On refreshing the page how can i focus the cursor automatically to the textbox of 'First'.
<script>
$( "#target" ).focus();
</script>
In QCubed, the Form_Create method of the QForm class executes during a page refresh. (Form_Run executes on both refreshes and ajax calls).
It looks like you are using the older v2 of QCubed, so you can do this in your Form_Create function after defining your datagrid and columns:
$filterId = 'ctl' . $this->dtgContent->ControlId . 'flt0';
$this->GetControl($filterId)->Focus();
$filterId should be the javascript id of the First field. Double check by looking at the html. $this is the form object.
It can be done easily like this,
just change the name col to col1
$col1 = new QDataGridColumn('First', '<?= $_CONTROL->ParentControl->renderFirst($_ITEM) ?>');
$col1->HtmlEntities = false;
$col1->OrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin);
$col1->ReverseOrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin, false);
$col1->Filter = QQ::Like(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin, null);
$col1->FilterType = QFilterType::TextFilter;
$col1->FilterPrefix = $col->FilterPostfix = '%';
$col1->Width = 170;
$this->dtgContent->AddColumn($col1);
then,
$ctrFilter = $this->dtgContent->GetFilterControl($col1);
$ctrFilter->Focus();
I am creating CSV from fetching data from MySQL data base. there are around 18000 rows and 8 columns but it show me Page unresponsive error and show me kill page or wait:
I've used following code.
function report_print()
{
date = time();
$myFile = "report_$date.csv";
$this->load->library('parser');
$stringData = $this->input->post('data');
$fileArray = $this->getdata($stringData);
$this->generateconvert_to_csv($fileArray, $myFile, ',');
die;
}
I have also tried to create CSV with jQuery with following code but it shows me error for " Network fail".
jQuery.fn.tableToCSV = function() {
var clean_text = function(text){
text = text.replace(/"/g, '""');
return '"'+text+'"';
};
$(this).each(function(){
var table = $(this);
var caption = $(this).find('caption').text();
var title = [];
var rows = [];
$(this).find('tr').each(function(){
var data = [];
$(this).find('th').each(function(){
var text = clean_text($(this).text());
title.push(text);
});
$(this).find('td').each(function(){
var text = clean_text($(this).text());
data.push(text);
});
data = data.join(",");
rows.push(data);
});
title = title.join(",");
rows = rows.join("\n");
var csv = title + rows;
var uri = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv);
var download_link = document.createElement('a');
download_link.href = uri;
var ts = new Date().getTime();
if(caption==""){
download_link.download = ts+".csv";
} else {
download_link.download = caption+"-"+ts+".csv";
}
document.body.appendChild(download_link);
download_link.click();
document.body.removeChild(download_link);
});
};
Anyone's Help will be appreciated for how to create a CSV with this much record without any issue ?
I have this code on .fla file
fm_button.visible = false;
var menu_label:Array = new Array("Introduction", "Products", "Services",
"Testimonials", "Our Company", "Contact Us");
var total:Number = menu_label.length;
var i:Number = 0;
var page:Number;
var main_menu:MovieClip = new MovieClip();
stage.addChild(main_menu);
for (i = 0; i < total; i++)
{
var btn = new flashmo_button();
btn.name = "btn" + i;
btn.x = fm_button.x;
btn.y = fm_button.y + i * ( fm_button.height + 10 );
btn.buttonMode = true;
btn.item_no = i;
btn.flashmo_click_area.addEventListener( Event.ENTER_FRAME, btn_enter );
var each_substring:Array = menu_label[i].split("|");
btn.flashmo_button_label.fm_label.text = each_substring[0];
btn.item_url = each_substring[1];
main_menu.addChild(btn);
}
function btn_over(e:MouseEvent):void
{
e.target.parent.over = true;
}
function btn_out(e:MouseEvent):void
{
e.target.parent.over = false;
}
What i want is to get this values:
("Introduction", "Products", "Services", "Testimonials", "Our
Company", "Contact Us");
from a text or php file named menu.php or menu.txt
Is this possible?
Why you need read from .php file?
Is this client-server communication?
In that case, when .fla file loads by client browser over http(s) you should do something like this:
menu.php (for example put this file to document root folder):
<?php $menu = array('Elem1', 'Elem2');
echo json_encode($menu); ?>
.fla:
var sendData:URLVariables = new URLVariables();
var request:URLRequest = new URLRequest('/menu.php');
request.method = URLRequestMethod.GET;
var loader:URLLoader = new URLLoader(request);
loader.addEventListener(Event.COMPLETE, onCompleted);
So, your .fla are doing query to server and get's list of categories (onCompleted method receive data).
If this is not server-client communication, you should use other file format, because .php is not a data storage )
I've written the conditions down in JavaScript and if it's a down arrow then I want to update the database whereas currently it's not falling into the javascript condition and updating the database at server level. Any help will be appreciated.
Code:
<script language="javascript">
$(document).ready(function() {
totalgames=<?= $totalgames ?>;
//scoress = 0;
previous_s=0;
for(xx=totalgames; xx>=1; xx--){
score_ele = 'scores'+xx;
tdid_ele = 'tdid'+xx;
var tdd = document.getElementById(tdid_ele);
var scoress = document.getElementById(score_ele);
if(previous_s == 0){
tdd.innerHTML = "<img src='images/bullet.png'/>";
}else{
if(parseFloat(previous_s) > parseFloat(scoress.value)){
tdd.innerHTML = "<img src='images/arrow_up.png'/>";
}else if(parseFloat(previous_s) < parseFloat(scoress.value)){
tdd.innerHTML = "<img src='images/arrow_down.png'/>";
<?php
//Selecting from table teams
$sql_sel_amnt = "Select * from teams where t_name='".$t_name."'";
$result_sel = $db1->getResult($sql_sel_amnt);
$row_sel = mysql_fetch_assoc($result_sel);
//Selecting from table profitnloss
$sql_pnl = "Select * from profitnloss where t_name='".$t_name."' and username='".$abc."'";
$result_pnl = $db1->getResult($sql_pnl);
$row_pnl = mysql_fetch_assoc($result_pnl);
$transact_money = $row_pnl['pnl_amount'];
$pnl_results = $row_pnl['pnl'];
$profit = 0;
$loss = 0;
$transact_money = explode("|", $transact_money);
$pnl_results = explode("|", $pnl_results);
for($i=0; $i<count($transact_money); $i++){
if($pnl_results[$i]=='P'){
$profit = $profit + $transact_money[$i];
}else{
$loss = $loss + $transact_money[$i];
}//end if
}//end for..
$money_results_total = $profit - $loss;
$pnl_date = date("d-m-Y H:i:s");
$pnl_amount = $row_sel['c_amount'];//total amount lost
$t_amount = $money_results_total + $row_pnl['t_amount'] + $pnl_amount;
$noofplayers = mysql_num_rows($result_sel)-1;//total no of players
$company_share = 17;//charity percentage
$company_share_amnt = $company_share*$pnl_amount/100;
$pnl_amount_remaining = $pnl_amount - $company_share_amnt;
$charity = substr($row_sel['charity'], 0, 2);//charity percentage
$charity_amount = $charity*$pnl_amount_remaining/100;
$sharing_amount = $pnl_amount-$charity_amount-$company_share_amnt;
$pnl_profit = round($sharing_amount/$noofplayers, 2);
echo "noofplayers=> ".$noofplayers.", company_share=> ".$company_share.", company_share_amnt=> ".$company_share_amnt.", charity=> ".$charity."%, charity_amount=> ".$charity_amount.", sharing_amount=> ".$sharing_amount.", pnl_profit=> ".$pnl_profit;
$sql_updt_loss = "UPDATE profitnloss SET game_date = '".$serial_date."', pnl_date = CONCAT(pnl_date, '$pnl_date|'), pnl_amount = CONCAT(pnl_amount, '$pnl_amount|'), pnl = CONCAT(pnl, 'Loss|'), t_amount='".$t_amount."' where username='".$abc."' and t_name='".$t_name."'";
//echo $updt_pnl;
//$result_loss = $db1->getResult($sql_updt_loss);
$sql_updt_profit = "UPDATE profitnloss SET pnl_date = CONCAT(pnl_date, '$pnl_date|'), pnl_amount = CONCAT(pnl_amount, '$pnl_profit|'), pnl = CONCAT(pnl, 'Profit|') where username not like'".$abc."' and t_name='".$t_name."'";
//echo $updt_pnl;
//$result_profit = $db1->getResult($sql_updt_profit);
?>
}else if(parseFloat(previous_s) == parseFloat(scoress.value)){
tdd.innerHTML = "<img src='images/bullet.png'/>";
}//end if
}//end if 0..
previous_s = document.getElementById(score_ele).value;
}//end for
})//emd document ready..
</script>
The way you should execute you PHP-code using ajax is by moving the server side code to a separate file which you call apon in the ajax-request, the url.
One example is using jQuery.
$.ajax({
type: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
This documentation is located here
You send the information needed to execute the PHP-code in the data. These are then accessed by $_POST or $_GET depending on which type you chose.
If you're not intending to use jQuery, you can look here: Getting Started with AJAX - Updating Form via PHP.
Here are some good practices using ajax
I'm trying to modify the Storm Flash MP3 player to record the artist name and title of a played/unplayed song. The author updated the player to skip a song if there is an IO Error.
I found the code below and it works for songs that played. For some reason, when I add it to the IOError function, it doesn't work at all.
I am a novice when it comes to Flash. Any help would be appreciated.
//Record Played Song Info via PHP script
scriptVars.var1 = "1+" + String(aMP3Tracks[iCurrTrack][1] + "+" + aMP3Tracks[iCurrTrack][2]);
scriptVars.var2 = (scriptDate);
scriptRequest.method = URLRequestMethod.POST;
scriptRequest.data = scriptVars;
scriptLoader.load(scriptRequest);
//End of Record Played Song Info via PHP script
Play Function
function playMP3():void {
tMP3Transform.volume = nCurrVolume;
schMP3 = sMP3.play();
schMP3.soundTransform = tMP3Transform;
**//Record Played Song Info via PHP script
scriptVars.var1 = "1+" + String(aMP3Tracks[iCurrTrack][1] + "+" + aMP3Tracks[iCurrTrack][2]);
scriptVars.var2 = (scriptDate);
scriptRequest.method = URLRequestMethod.POST;
scriptRequest.data = scriptVars;
scriptLoader.load(scriptRequest);
//End of Record Played Song Info via PHP script**
if(mcStormHolder.mcPlayBtn.currentFrame >= 20) {
schMP3.stop();
}
schMP3.addEventListener(Event.SOUND_COMPLETE, incrementTrack, false, 0, true);
removeEventListener(Event.ENTER_FRAME, updateViz);
bForceRandom = false;
addEventListener(Event.ENTER_FRAME, updateViz, false, 0, true);
}
IOERROR Function
function onMP3IOError(e:IOErrorEvent):void {
trace("An IO error occurred while attempting to load the MP3 track.");
//sMP3.removeEventListener(Event.COMPLETE, onMP3Loaded);
sMP3.removeEventListener(IOErrorEvent.IO_ERROR, onMP3IOError);
sMP3.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onMP3SecurityError);
//incrementTrack();
mcStormHolder.mcInfoBar.txInfo.text = String(aMP3Tracks[iCurrTrack][1] + " - " + aMP3Tracks[iCurrTrack][2]);
mcStormHolder.mcInfoBar.txInfo.autoSize = TextFieldAutoSize.LEFT;
mcStormHolder.mcInfoBar.txInfo.x = 50;
//Record Song if for songs that did not play
scriptVars.var1 = "0+" + String(aMP3Tracks[iCurrTrack][0]);
scriptVars.var2 = (scriptDate);
scriptRequest.method = URLRequestMethod.POST;
scriptRequest.data = scriptVars;
scriptLoader.load(scriptRequest);
//Record Song if for songs that did not play
//Begin Modification for Roger Stull - Skip song if will not load
abortLoad();
bForceRandom = false;
if (schMP3 != null) {
schMP3.stop();
schMP3.removeEventListener(Event.SOUND_COMPLETE, incrementTrack);
nPausePos = 0;
iCurrTrack = iCurrTrack + 1;
if(iCurrTrack > iNumTracks-1){
iCurrTrack = 0;
}
sMP3 = new Sound();
schMP3 = new SoundChannel();
loadMP3();
}
//End Modification for Roger Stull
}