1

Im working on a tile based tmx editor and currently have file saving working. Currently it passes the tmx to a php file called endpoint that downloads the file. it can be viewed here www.jamesplanet.net/growtopiamapeditor/beta.

What I need to know is it possible to use php to upload a file then pass the file to javascript to load into the editor?

If you need a copy of the source I can put a link

If this question isn't worded correctly or hasn't enough information please don't down vote. instead let me know what else you need to know.

Jamesp1989
  • 325
  • 1
  • 4
  • 11
  • 1
    Try researching the HTML5 FileReader: https://developer.mozilla.org/en-US/docs/DOM/FileReader, you won't even have to go through your server. I use it on my list randomizer: http://derek.genevievehoward.com/projects/6/index.php – howderek Mar 27 '13 at 16:08
  • http://stackoverflow.com/questions/10091154/php-ajax-file-upload – ficuscr Mar 27 '13 at 16:09
  • I have used different solutions but cannot get it to play ball with my code – Jamesp1989 Mar 27 '13 at 16:11

2 Answers2

0

Basically this need to work , you have to use iframe , which you can create on the fly and use it as posted back to php code. This is one of the common way to achieve this. There will so many third party using this concept

Devesh
  • 4,500
  • 1
  • 17
  • 28
0

Possible solution: You could have the PHP script download the file, insert the file details into a table and only return a name and/or id of how to get the file details from the table in JSON format for the javascript to add the file to the list.

Hayden
  • 2,082
  • 1
  • 14
  • 18
  • As a tmx file is basicly xml would I be better off using a system of generating xml to a text box when saving and have a box the xml can be pasted into for loading? – Jamesp1989 Mar 27 '13 at 17:51
  • Ah, I had never used a 'tmx' file before, so I presumed it was a binary file since you mentioned downloading it. Could still have the PHP script read whatever data it needs from the file and return it in a JSON object to the javascript to then later be posted. You would basically be using the PHP script to translate it from tmx to json. – Hayden Mar 27 '13 at 17:57