Search the web
Sign In
New User? Sign Up
wo-support · webOutliner support
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Re: iJot feedback   Message List  
Reply | Forward Message #25 of 26 |
Re: iJot feedback

>> Do you mean writing code to reply to the user clicking the browse button in
>> the 'open outline' dialog in order to load an OPML outline from his local
>> workstation ?

"Dirk Wintergruen" <dwinter@...> wrote:
> yes

Ok, I do not know how Zope processes INPUT type="file" HTML for fields in
http POST requests, but here is how we process it in iJot's PHP back-end:

<body>
<script type="text/javascript">
<?php

$err = '';
define ('MAXSIZE', 1024 * 1024);
// max file size is 1 Mb.

if (! $_FILES['file']['error']) {
// check for errors, 0 = no error

if ($_FILES['file']['tmp_name']) {
// check file existence
$name = $_FILES['file']['name'];
$type = $_FILES['file']['type'];
$size = $_FILES['file']['size'];

if ($size) {
// check file existence

if ($size <= MAXSIZE) {
// check file size

if (preg_match ('/opml$/', $type) || preg_match
('/\.opml$/', $name)) {
$tmpUrl = "/tmp/imports/$name";
// url to temporary file
$tmp = realpath ($_SERVER['DOCUMENT_ROOT']) .
$tmpUrl; // path to temporary file

if (! copy ($_FILES['file']['tmp_name'], $tmp)) {
$err .= "Unable to retrieve local outline.";
} else {
echo "parent.loadXMLDoc (\"$tmpUrl\");\n";
}
} else {
// or error message
$err = "$name does not appear to be an OPML
outline.";
}
} else {
$err = 'maximum allowed size for outline files is ' .
MAXSIZE . ' bytes.';
}
} else {
$err = 'file not found. please use the browse button to
select an outline.';
}
} else {
$err = 'file not found. please use the browse button to select
an outline.';
}
} else {
// some error was detected

switch ($_FILES['file']['error']) {

case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$err = 'maximum allowed size for outline files is ' .
MAXSIZE . ' bytes.';
break;

case UPLOAD_ERR_PARTIAL:
$err = 'outline file was only partially uploaded.';
break;

case ERR_NO_FILE:
$err = 'Please supply an outline file for upload using the
browse button.';
break;

default:
$err = 'upload failed.';
break;
}
}

if ($err) {
echo "parent.document.getElementById ('titleDiv').innerHTML =
'Error: $err';\n"; // format msg
as javascript
}

?>
</script>
</body>


The open dialog form is posted using a hidden IFRAME of the webOutliner
window as target.

The PHP response to the POST request generates Javascript code which
executes in that hidden IFRAME depending on how the upload goes...

If all goes well, we call webOutliner's loadXMLDoc function, passing the url
of the uploaded OPML doc, stored in a temporary location.

If not, we display an error message.

HTH

Marc



-----------
Marc Barrot
Precision IT Management, Inc
marc@...





Fri Jun 30, 2006 2:17 pm

mb1022002
Offline Offline
Send Email Send Email

Forward
Message #25 of 26 |
Expand Messages Author Sort by Date

... The example proxy PHP code is for opening OPML outlines in the outliner that are not originating from the same server as the weboutliner window itself, to...
Marc Barrot
mb1022002
Offline Send Email
Jun 30, 2006
2:10 pm

... Ok, I do not know how Zope processes INPUT type="file" HTML for fields in http POST requests, but here is how we process it in iJot's PHP back-end: <body> ...
Marc Barrot
mb1022002
Offline Send Email
Jun 30, 2006
4:04 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help