November 9, 200817 yr Ok guys, this is what i want to do INPUT: User uploads a photograph (which can be different formats) to the server. PROCESS: [server does jiggery pokery that creates the output below] OUTPUT: An automatically generated xml file in the following format: <images> <pic> <image>Directory of Image</image> </pic> <pic> <image>Directory of Image</image> </pic> </images> Each <pic></pic> element will be ONE description of an image. This in turn will work with Actionscript in flash (let not worry about that for now lol). Basically the end result is: Client simply drops files onto a folder in the server------> XML file tells flash to show those pictures with nice animation etc without the client doing anything. It is the PROCESS that has got me... what exactly do i need to do? I need to have some sort of server process that 1. Detects the photos (files) on the server 2. Grab their filename and directory 3. Uses the filename to create inside the <image></image> element on an XML sheet, and update this dynamically. I assume there is PHP and MySQL involved... MUCH help would be appreciated. ThankyoU!!!!!
November 9, 200817 yr this maybe a poorly coded script but in fairness ive just coded it in the forum reply box... but it should work it will scan any directory and provide you a xml file to the structure you need, all you need todo is the uploading and setting what the value for $dir needs to be // find out the directory of the files... ether its default and hard coded or dynamic // path below assumes your on a cpanel server $dir = '/home/account/public_html/images/uploads/'; // url for the images $url = 'www.test.com'; // scan dir and return as array $image_directory = scandir($dir, 1); // the one sets the ordering so the newest file is top of the array // set the header of this file as xml header('Content-type: application/xml'); // start xml echo '<?xml version="1.0" encoding="UTF-8"?> <images>'; // loop through the images in the folder set in $dir for($image = 0; $image < sizeof($image_directory); $image++){ // scandir() picks up some files that arnt there so if not those if ($image_directory[$image] != "." && $image_directory[$image] != "..") { // echo image xml data echo "<pic> <image>$url/$image_directory[$image]</image> </pic>"; } } // echo last xml part and exit echo '</images>'; exit(); as far as i see it this is the process you are looking for... just needs the bits around it hope that helps
November 10, 200817 yr Author I tried to implement your code but I am confused. I did not mention this but my knowledge of PHP only goes as far as 'reverse engineering' other code. I cannot begin from scratch. Just to summarize. There are images on my website at www.perius.co.uk/AidahRauf/images There are four folders that contain images in the images folder: /fashion /bricks and spaces /family docu So i need some pointers: 1. I am not on a cpanel server, I am with godaddy, they have their own hosting thing, so for $dir i assume that i just put the directory of where the images are uploaded. So do I need to make a PHP file for each folder in images? So for example For /fashion, i have the PHP file in /AidahRauf and for its $dir i have: $dir = '/images/fashion/'; 2. I am confused about the $url do I just put the same as the directory then? In your comment you say its for the images, but I dont want to have to write the url of each image out, otherwise i would just write my own XML document! Anyway when I run the script with $dir = '/images/fashion/'; $url = 'www.perius.co.uk/AidahRauf/images/'; I get the following: Parse error: syntax error, unexpected T_STRING in /home/content/p/e/r/periusdesign/html/AidahRauf/xmlgenerator.php on line 11 Sorry to be a pain! Steve
November 10, 200817 yr fairplay steve, sorry dude i thought you knew how to program from scratch and just needed someone to point out a way of getting a process that does x,y & z. right ive got some questions to help me understand how you want this to work... so 1) is this a membership system? (i.e will there be lots of directory's created one for each user? or is it one directory for ALL uploads) 2) is this a system to make your life easier rather than a service? 3) do you need a feed per directory of images or all images in all directorys in one feed? if you said yes to 1 - do you have a member system setup? i can code this up my end to a working order and email/post the full system or if your stuck with ftp details i can get this running in your environment for you
November 11, 200817 yr Author fairplay steve, sorry dude i thought you knew how to program from scratch and just needed someone to point out a way of getting a process that does x,y & z. right ive got some questions to help me understand how you want this to work... so 1) is this a membership system? (i.e will there be lots of directory's created one for each user? or is it one directory for ALL uploads) 2) is this a system to make your life easier rather than a service? 3) do you need a feed per directory of images or all images in all directorys in one feed? if you said yes to 1 - do you have a member system setup? i can code this up my end to a working order and email/post the full system or if your stuck with ftp details i can get this running in your environment for you Ok ok, well first of all, I would really love to learn the ability to do this myself, so for now I would rather you help me then do it for me ... 1.) It is not a membership system, it is purely for a friend who knows her ftp login and password, and all she needs to do is upload her pictures quite simply to the server. 2.) It is not to make my life easier, this is at the request of a friend 3.) What do you mean by 'feed'? I need an XML document generated for each folder which is /family /fashionandportraits /nature /sin /spaces Thankyou!!!
November 11, 200817 yr if you want 4 feeds/xml docs to gather the info then you put one file in each folder, but this line needs changing since you might call the file xmlgenerator.php from the same Dir as the images we need to make sure the xml doc dosnt contain the php url FIND if ($image_directory[$image] != "." && $image_directory[$image] != "..") { REPLACE WITH - if ($image_directory[$image] != "." && $image_directory[$image] != ".." && $image_directory[$image] != "xmlgenerator.php") { that php error you are getting is because my Php IDE lies... yes zend lies to! FIND echo '<?xml version="1.0" encoding="UTF-8"?> <images>'; REPLACE WITH- echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><images>"; the $url for you should be http://www.perius.co.uk/AidahRauf/images/ if you are putting a copy of the script in each folder because you want 4 feeds then add the folder name to the url. if you want to have one feed for all 4 directory's, we need to put in some loops and funky extras
November 11, 200817 yr assuming you have made the code chages above the $dir value needs tobe /home/content/p/e/r/periusdesign/html/AidahRauf/images/fashion/ that will get it working in theory
November 11, 200817 yr Author assuming you have made the code chages above the $dir value needs tobe /home/content/p/e/r/periusdesign/html/AidahRauf/images/fashion/ that will get it working in theory Thank you for your continuing help! Much appreciated! Regrettably I am still getting errors with the example at http://www.perius.co.uk/AidahRauf/images/f...mlgenerator.php ...this is beyond me
November 11, 200817 yr try removing the comments, it could be the word array as it was line wraped in my post. ive just uploaded the script to my site http://www.websnobery.com so you can see it works.... honest
November 11, 200817 yr Author $dir = '/home/content/p/e/r/periusdesign/html/AidahRauf/images/family/'; $url = 'http://www.perius.co.uk/AidahRauf/images/family'; $image_directory = scandir($dir, 1); header('Content-type: application/xml'); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><images>"; for($image = 0; $image < sizeof($image_directory); $image++){ if ($image_directory[$image] != "." && $image_directory[$image] != ".." && $image_directory[$image] != "xmlgenerator.php") { echo "<pic> <image>$url/$image_directory[$image]</image> </pic>"; } } echo '</images>'; exit(); The above is how I have uploaded it to no avail.
November 11, 200817 yr Author Okay, produces an XML echo perfectly like your site, however, and the last thing i need to say before i go to bed is, i need the output to be written to an XML file, called images.xml.. At the moment it just displays it at the PHP file. This is so actionscript can read it. Thanks!!!
November 11, 200817 yr the content header is XML, the content is XML it is a dynamicly produced XML document. it should work file, the same as you can use a .php file for image and css sources... but... with mod_rewrite you can make is appear to be a xml doc not php but it dosnt matter... this is XML you can add a mod_rewrite, to a .htacsess file RewriteEngine On RewriteRule images.xml xmlgenerator.php also those folders can only have image files and the script in there or you will get problems.
November 12, 200817 yr Author Snider, thankyou for helping me combine actionscript, XML, PHP, and mod_rewrite on this forum and on IM. You are a genius! Ive got things running perfectly!
Create an account or sign in to comment