View Full Version : xml photo gallery admin side

04-11-2007, 09:07 AM
Hi everyone,
I'm using a flash xml gallery with an xml to parse the images.
my xml is very simple:
<?xml version="1.0" encoding="UTF-8"?>
<gallery name="kimono">
<image source="pics/K_prev001.jpg" thumb="pics/K_th001.jpg" title="kimono01" bonus="test1"/>
<image source="pics/K_prev002.jpg" thumb="pics/K_th002.jpg" title="kimono02" bonus="test2"/>
<image source="pics/K_prev003.jpg" thumb="pics/K_th003.jpg" title="kimono01" bonus="test3"/>
<image source="pics/K_prev004.jpg" thumb="pics/K_th004.jpg" title="kimono04" bonus="test4"/>


<gallery name="qipao">
<image source="pics/Q_prev001.jpg" thumb="pics/Q_th001.jpg" title="qipao01" bonus="bob1"/>
<image source="pics/Q_prev002.jpg" thumb="pics/Q_th002.jpg" title="qipao02" bonus="bob2"/>
<image source="pics/Q_prev003.jpg" thumb="pics/Q_th003.jpg" title="qipao03" bonus="bob3"/>


how can i create a admin interface so the user will just have to upload his file and write a description text in a field and it will update the xml.

I'm not sure how to proceed but I guess it will be something like:
html/php ----> (uploaded image, text ) MySQL ,
MySQL data ------> collected by php
php ------> update xml.
I can't seems to find a tutorial to just implement images and description text for a flash/xml gallery.
I can't do php or MySQL but If I have a tutorial will be great so I could do this.

thanks for the help.

04-24-2007, 02:15 PM
I'm looking for the exact same thing. A tutorial for this would be awesome... :confused: ;)

05-01-2007, 08:16 PM
this is actually pretty simple.

First off how to write a file upload fuction in PHP http://www.phpfreaks.com/tutorials/85/0.php

Here's how to use flash with PHP

then to write you're XML file you use the sample code up on php.net

You'll probably have questions so feel free to ask as you read through that stuff.

05-04-2007, 12:15 AM
I don't know if this ever got worked out, but I'm preparing to do something similar and I am a little stuck on how to get started.

here is my thinking so far.

I have a SWF with the gallery (which in my case is a menu)--this is no problem, I think I'm OK with that.

I'll need an XML file to feed the gallery it's images--this too is no problem.

here's where I get a little confused:

I also need an admin area where the client can load in new pictures and text. I suspect this will be another SWF that will somehow edit the XML document (loadVars?) and upload the new content via PHP. I know how to do the upload part of the PHP, but I'm not sure how to revise the XML via the admin panel...any help would be great.

the middle link given above no longer works so maybe I missed a crucial part.

Thanks in advance! I appreciate your help.

05-04-2007, 07:35 PM
humm.. that link got cut off, it's just in tutorial section here on AS.org, I would read it (just search for "Introduction to Flash and PHP" here http://www.actionscript.org/resources/articles) because it covers the basics of sending and receiving variables.

I'm not quite sure what you mean by "revise the XML" via the admin panel, are you talking about just appending what you created onto the end of an XML file?

So for example taking the original XML here:

<user name="bob account="34334143">
<picture name="myPictureOne.jpg">[!CDATA["I like cheese"]]</picture>

I assume you'd want to be able to take this and then add in either new users or new photos to a user correct?

Well the easiest way I'd do this is recreate the whole XML, but I'd break it down (again assuming you're is like my example) and create multiple XML files.

The first one would be a users XML file that would just contain the user name and an unique id (account number in my example) then have a separate XML file for each username and/or unique id.

So if you want to add a new user you load the user XML file into flash break it apart into an array then add the new user into the array and recreate the XML. Or you could do a search for the node that contains the closing tag of the XML file and insert the new user in that way.

Same thing with adding or changing a user's gallery, since you've broken up the users into individual files you don't have to worry about searching for one person in a large file and you can do this the same way.

Once that's done you export back to PHP and just have the newly created XML file overwrite the old one.

Or you can send the information to PHP either formatted into XML via flash or you can do it in PHP and then search the XML file (as text in this case) and throw it where you want it.

Either of these methods will work, just depends on what you want to do or are comfortable doing. I'll be happy to help code wise if you can't figure out how to do any of them.

Hopefully this was what you were looking for.