I'm a javascript guy getting too deep into php (even though this question is not deep).
I am passing two different variables in the url from file to file. One goes across fine while the other does not.
I have 2 files. upload.php and uploadfiles.php.
The params help construct the destination to which the files are uploaded.
The two params are "memberId" and "fileType".
Here is where I pass the params to uploadfiles.php, this code is on upload.php.
Its in two places. One for a hidden input for a form and another passed as a var to a flash script.
On form:
<input name="uploadscript" id="uploadscript" type="hidden" value="/flashuploader/FileProcessingScripts/PHP/uploadfiles.php?memberId=<?php echo $_REQUEST["memberId"] ?>&fileType=<?php echo $_REQUEST["fileType"] ?>" />
In the js:
uploadUrl: '/flashuploader/FileProcessingScripts/PHP/uploadfiles.php?memberId=<?php echo $_REQUEST["memberId"] ?>&fileType=<?php echo $_REQUEST["fileType"] ?>'
I have tested on upload.php that $_REQUEST["fileType"] does indeed have the correct value.
And then I retrieve the params on uploadfiles.php like so:
$uploaddir=realpath(dirname(__FILE__) . '/../../../memberimages/') . '/'.$_REQUEST["memberId"].'/My_Files/'.$_REQUEST["fileType"].'/';
Param "memberId" works fine, but "fileType" is empty. I'm sure it has to do with the way that I am adding the params to the url with php on upload.php but I'm out of ideas.
Here is the html produced and returned by upload.php. You can see the values look correct on lines 44 and 80:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function mysubmit(type)
{
if(document.getElementById("uploadscript").value=='')
{
window.alert('Enter upload processing script file name!');
return false;
}
if(type=='flash')
{
MultiPowUpload.uploadAll(document.getElementById("uploadscript").value);
document.getElementById("server_reply").value="";
}
else
{
var FormObj = document.getElementById("myform");
FormObj.action = document.getElementById("uploadscript").value;
return true;
}
}
function MultiPowUpload_onComplete(type, index, serverResponse)
{
var reply;
reply = document.getElementById("server_reply");
reply.value += "\nReply for file: " + MultiPowUpload.fileList()[index].name + "\r\n" + serverResponse + "\n";
}
var fileType = 'Video';
function MultiPowUpload_onCompleteAbsolute(type, uploadedBytes)
{
if (fileType == 'Video'){
parent.loadUserVideos();
} else if (fileType == 'Images') {
parent.loadUserImages();
}
}
</script>
<div style="margin-top: -20px">
<input name="uploadscript" id="uploadscript" type="hidden" value="/flashuploader/FileProcessingScripts/PHP/uploadfiles.php?memberId=43&fileType=Video" />
<table width="380" cellpadding="0" cellspacing="0">
<tr>
<td style="position: relative;">
<div id="MultiPowUpload_holder" style="margin-top: 20px">
<table width="380" cellpadding="0" cellspacing="0">
<tr>
<td>
<form id="myform" onSubmit="return mysubmit();"
enctype="multipart/form-data" action="" method="POST">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="106"><span
style="font-family: Arial, Helvetica, sans-serif; font-size: 12px">Select
file:</span></td>
<td width="294"><input name="Filedata" type="file" /></td>
</tr>
</table>
<br>
<input type="submit" value="Upload File" /></form>
</td>
</tr>
</table>
</div>
<!-- <img src="/images/ajax-loader.gif" style="position:absolute; top:40%; left:50%; margin-left:-110px;" /> -->
<!-- SWFObject home page: http://code.google.com/p/swfobject/ --> <script
type="text/javascript" src="/flashuploader/swfobject.js"></script> <script
type="text/javascript">
var params = {
BGColor: "#FFFFFF"
};
var attributes = {
id: "MultiPowUpload",
name: "MultiPowUpload"
};
var flashvars = {
uploadUrl: '/flashuploader/FileProcessingScripts/PHP/uploadfiles.php?memberId=43&fileType=Video',
uploadButtonVisible: "Yes",
useExternalInterface: "Yes",
maxFileSize: "6024000",
maxFileCount: "20",
maxFileSizeTotal: "20480000",
backgroundColor: "#FFFFFF",
buttonTextColor: "#000000",
buttonBackgroundColor: "#F1F1F1",
buttonBottomBorderColor: "#E1E1E1",
buttonTopBorderColor: "#E1E1E1",
buttonDisabledBackgroundColor: "#FFFFFF",
buttonDisabledBottomBorderColor: "#DDDDDD",
buttonDisabledTopBorderColor: "#DDDDDD",
buttonDisabledTextColor: "#DDDDDD",
buttonRollOverBottomBorderColor: "#666666",
buttonRollOverTopBorderColor: "#666666",
buttonDownBottomBorderColor: "#000000",
buttonDownTopBorderColor: "#000000",
buttonDownBottomBackgroundColor: "#FFFFFF",
buttonDownTopBackgroundColor: "#FFFFFF",
listTextSelectedColor: "#000000",
listTextRollOverColor: "#333333",
listRollOverColor: "#DDDDDD",
listDownColor: "#EEEEEE",
listSelectedUpColor: "#EEEEEE",
listSelectedRollOverColor: "#D2D2D2",
listUnuploadedColor: "#777777",
listUploadedColor: "#FFFFFF",
progressBarLeftColor: "#BBBBBB",
progressBarRightColor: "#AAAAAA",
progressBarLeftBorderColor: "#E1E1E1",
progressBarRightBorderColor: "#E1E1E1",
textColor: "#FFFFFF"
};
swfobject.embedSWF("/flashuploader/ElementITMultiPowUpload2.1.swf", "MultiPowUpload_holder", "380", "270", "9.0.0", "/flashuploader/expressInstall.swf", flashvars, params, attributes);
</script></td>
</tr>
</table>
</div>
</body>
Thanks for the help!