TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-04-2008, 06:39 PM   #1 (permalink)
The Frequenter
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 440
Thanks: 3
xenon is on a distinguished road
Default Aptana Jaxer and file uploads

Hey guys. I need an advice about some paths. Well, I developed a file manager (let's say it's something like the Windows Explorer - a simple system navigator) using Aptana's Jaxer. Now, in Javascript I only have the filesystem paths (on windows they will be like C:/dir/file.jpg, for example). How would I upload these paths using only Javascript and PHP (if possible)? I've tried this, so far:

1. create a hidden form, with a file input inside it. The idea was to populate the file input with one path at a time, and then submit the form inside an iframe or something like that (so I would also get a response from the server). That didn't work, as the file type inputs are read-only. I also tried using a file input and a hidden input with the same name, but that didn't work either.
2. use Jaxer's file management functions (tried to read a local file into a buffer and send pieces to the server to rebuild the file). The only problem is that I receive an error when reading from a non-text file (a JPEG, for instance), where the contents are not in utf-8 encoding. So this won't work, either.

A solution would be to use an additional SWF file for the communication between javascript and PHP, therefore getting the ability to build a progress bar, aswell. But, I can do that from Javascript too, if just I could read the file somehow...

LE: by 'uploading the paths' I mean uploading the files on the local filesystem with that specific path.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.

Last edited by xenon : 06-05-2008 at 12:04 AM.
xenon is offline  
Reply With Quote
Old 06-05-2008, 06:02 PM   #2 (permalink)
The Visitor
 
Join Date: Jun 2008
Posts: 1
Thanks: 0
davey is on a distinguished road
Default

Xenon,

Quick Introduction, I'm Davey and work @ aptana on Jaxer, and would be happy to help you get your project moving forward.

I dont quite follow your description of what you are trying to do. But at least one thing jumped out at me which was that you are trying to read binary files with Jaxer, the API for that is slightly different from the regular files, when you open the file using the open method on a file instance, you should provide the open mode parameter for binary access which is 'rb' the code would like some thing like.

Code:
var f = new Jaxer.File(myPath);
f.open('rb');
var binData = f.read(); // may need to chunk it out if very large
f.close();
hope that helps.

We have Jaxer forums you can post questions and observation to ( Aptana Forums :: Jaxer )

let me know if you need more help.

cheers
davey
davey is offline  
Reply With Quote
Old 06-06-2008, 10:22 AM   #3 (permalink)
The Frequenter
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 440
Thanks: 3
xenon is on a distinguished road
Default

Hello Davey. What I'm trying to do is upload an image/mp3/video file to a server using Jaxer's file wrapper and some server-side language.

About your suggestion...I do know the file modes and how/when to use them. The only problem is that Jaxer's File readAllLines() method throws an error if trying to read a whole file's contents:

Code:
13:17:02 06/06/2008 [  2080] [ERROR] [JS Framework] [framework.onCallback] message: -----======[ jsLib ERROR ]=====-----
         FileName:          file:///C:/webserver/bin/jaxer/framework/JSLib.js
         Result:            -2147549183
         Message:           Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIScriptableUnicodeConverter.ConvertToUnicode]
         LineNumber:        1693
fileName: file:///C:/webserver/bin/jaxer/framework/serverFramework.js
lineNumber: 5990
name: Error
stack:
  -> error("message: -----======[ jsLib ERROR ]=====-----\n         FileName:          file:///C:/webserver/bin/jaxer/framework/JSLib.js\n         Result:            -2147549183\n         Message:           Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIScriptableUnicodeConverter.ConvertToUnicode]\n         LineNumber:        1693\nfileName: file:///C:/webserver/bin/jaxer/framework/serverFramework.js\nlineNumber: 5990\nname: Error",null,onCallback) [line 2665 of serverFramework.js (file:///C:/webserver/bin/jaxer/framework/serverFramework.js)]
  -> Exception([object Error]) [line 5946 of serverFramework.js (file:///C:/webserver/bin/jaxer/framework/serverFramework.js)]
  -> onCallback([object XPCWrappedNative_NoHelper],[object HTMLDocument]) [line 11138 of serverFramework.js (file:///C:/webserver/bin/jaxer/framework/serverFramework.js)]
  -> fire("CALLBACK",[object XPCWrappedNative_NoHelper],[object HTMLDocument]) [line 10102 of serverFramework.js (file:///C:/webserver/bin/jaxer/framework/serverFramework.js)]
  -> coreHTMLParseComplete([object XPCWrappedNative_NoHelper],"jaxerEvent.HTMLParseComplete",null) [line 64 of aptHTMLParseComplete.js (file:///C:/webserver/bin/jaxer/components/aptHTMLParseComplete.js)]
That's the response it throws me (I copied it from the Jaxer log file, but I get it as a javascript alert). Reading the file in chunks (16 kb at a time, for example), also throws the same error. The only solution would be to read the file byte by byte, but that causes a freeze of the browser.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:50 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design