Page 1 of 1

'post' parameter - cant get email notification to work

Posted: Wed Dec 16, 2009 12:45 am
by Mr5o1
Hi all,

great little applet - looking forward to getting it all working nicely so I can buy a license.

So far so good, I've got the sftp upload working, and included a "forward" parameter which works a treat.

I'm just having dramas with the post parameter - ive included it in the applet_sftp.js file in the same fashion as the "forward" parameter.

as you can see below, the post url is http://wheatcrofts.com.au/portal/email.php
if I type that url in my browser address bar it forwards me an email just fine.

I'll freely admit I'm a website / php amateur - didnt know much about it at all a few days ago.

Thanks in advance for any advice you might be able to offer me!

obviously every time you see !!removed!! in the code snippets below, its just where I've edited the text to post in this forum, I assume all the parameters I've edited in this way are ok, because both scripts work invidivually, just not together.

my applet_sftp.js file:

Code: Select all

<!--
var _info = navigator.userAgent;
var _ns = false;
var _ns6 = false;
var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
if (_info.indexOf("Opera") > 0) _ie = false;
var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX") > 0)));
var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
if (_ie == true) {
  document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="250" HEIGHT="250" NAME="fileupload" codebase="http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0">');
}
else if (_ns == true && _ns6 == false) { 
  // BEGIN: Update parameters below for NETSCAPE 3.x and 4.x support.
  document.write('<EMBED ');
  document.write('type="application/x-java-applet;version=1.4" ');
  document.write('CODE="jfileupload.upload.client.MApplet.class" ');
  document.write('JAVA_CODEBASE="./" ');
  document.write('ARCHIVE="lib/jfileupload.jar,lib/ftpimpl.jar,lib/cnet.jar,lib/clogging.jar,lib/sftpimpl.jar,lib/jsch.jar" ');
  document.write('NAME="fileupload" ');
  document.write('WIDTH="250" ');
  document.write('HEIGHT="250" ');
  document.write('url="sftp://!!removed!!" ');
  document.write('param1="username" ');
  document.write('value1="!!removed!!" ');
  document.write('param2="password" ');
  document.write('value2="!!removed!!" ');
  document.write('mode="ftp" ');
  document.write('scriptable=true ');
  document.write('post="http://wheatcrofts.com.au/portal/email.php" ');
  document.write('postparameters="true" ');
  document.write('forward="http://wheatcrofts.com.au/index.htm" ');
  document.writeln('pluginspage="http://java.sun.com/products/plugin/index.html#download"><NOEMBED>');
  // END
}
else {
  document.write('<APPLET CODE="jfileupload.upload.client.MApplet.class" JAVA_CODEBASE="./" ARCHIVE="lib/jfileupload.jar,lib/ftpimpl.jar,lib/cnet.jar,lib/clogging.jar,lib/sftpimpl.jar,lib/jsch.jar" WIDTH="250" HEIGHT="250" NAME="fileupload">');
}
// BEGIN: Update parameters below for INTERNET EXPLORER, FIREFOX, SAFARI, OPERA, MOZILLA, NETSCAPE 6+ support.
document.writeln('<PARAM NAME=CODE VALUE="jfileupload.upload.client.MApplet.class">');
document.writeln('<PARAM NAME=CODEBASE VALUE="./">');
document.writeln('<PARAM NAME=ARCHIVE VALUE="lib/jfileupload.jar,lib/ftpimpl.jar,lib/cnet.jar,lib/clogging.jar,lib/sftpimpl.jar,lib/jsch.jar">');
document.writeln('<PARAM NAME=NAME VALUE="fileupload">');
document.writeln('<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">');
document.writeln('<PARAM NAME="scriptable" VALUE="true">');
document.writeln('<PARAM NAME="url" VALUE="sftp://!!removed!!">');
document.writeln('<PARAM NAME="param1" VALUE="username">');
document.writeln('<PARAM NAME="value1" VALUE="!!removed!!">');
document.writeln('<PARAM NAME="param2" VALUE="password">');
document.writeln('<PARAM NAME="value2" VALUE="!!removed!!">');
document.writeln('<PARAM NAME="mode" VALUE="ftp">');
document.writeln('<PARAM NAME="post" VALUE="http://wheatcrofts.com.au/portal/email.php">');
document.writeln('<PARAM NAME="postparameters" VALUE="true">');
document.writeln('<PARAM NAME="forward" VALUE="http://wheatcrofts.com.au/index.htm">');

// END
if (_ie == true) {
  document.write('</OBJECT>');
}
else if (_ns == true && _ns6 == false) {
  document.write('</NOEMBED></EMBED>');
}
else {
  document.write('</APPLET>');
}
//-->
my own email.php file:

Code: Select all

<?php
$to = "!!removed!!";
$subject = "web portal upload notification";
$body = "something has been uploaded";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
?>

Re: 'post' parameter - cant get email notification to work

Posted: Wed Dec 16, 2009 1:03 am
by Mr5o1
hang on.. I found a post here:
viewtopic.php?f=8&t=187&start=0&hilit=email.php

which describes the process but uses the "forward" parameter to forward to email.php rather than the post parameter. I just tried it out and that works fine, I guess I can just use my email.php script to redirect after sending the email.

Is that the best method though? I read in the documentation that parameters (query strings?) can be truncated with the forward command, but not with the post command. the email.php that I've included here obviously doesnt utilise the parameters at all, but thats only because I was just trying to get it working in any form.

Thanks again.

Re: 'post' parameter - cant get email notification to work

Posted: Wed Dec 16, 2009 6:24 pm
by support
It should also work with "post" parameter. Your JavaScript file seems perfect. Do you notice any JavaScript error when the applet is loading ? Could you add a trace (in a file on server) to trace that email.php is really called (whatever HTTP GET or POST).

Re: 'post' parameter - cant get email notification to work

Posted: Wed Dec 16, 2009 11:08 pm
by Mr5o1
thanks for the response!

I think I'll just stick with a redirection in the email.php file. I dont really know what I'm doing and for now, using the "forward" method is working.. and you know what they say, if it works - dont fix it!

thanks very much.