erikjauli Posted March 18, 2009 Share Posted March 18, 2009 Hi... I'm very new to PHP and thanks to help on this forum I was able to build a dynamic image rotator using actionscript, xml, and php today. I have an swf with actionscript that calls a php file to generate an xml of a directories contents. The swf then creates a random slideshow based on that xml. The only problem I'm having is that the php script I am using includes ".DS_Store" in the generated XML. I think that is causing problems with the slideshow because it randomly stops when it should loop continuously. Im assuming when it tries to grab the .ds store file its causing this problem. Ive attached the php file, the model XML, and the generated xml. Any ideas? Thanks. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/150058-solved-php-xml-generator-including-ds_store-file/ Share on other sites More sharing options...
sloth456 Posted March 18, 2009 Share Posted March 18, 2009 I remember seeing a .ds_store when an apple mac machine interacts with a windows machine on a network. I'm thinking it probably is the problem, if there's anyway to avoid including it I would advise you do. Quote Link to comment https://forums.phpfreaks.com/topic/150058-solved-php-xml-generator-including-ds_store-file/#findComment-788109 Share on other sites More sharing options...
erikjauli Posted March 19, 2009 Author Share Posted March 19, 2009 i am currently building/managing/hosting the site locally on a mac using mamp. maybe once i migrate the site to an external host this issue will be resolved. curious if anyone else has experienced this problem before and how they've resolved it. thanks -Erik Quote Link to comment https://forums.phpfreaks.com/topic/150058-solved-php-xml-generator-including-ds_store-file/#findComment-788152 Share on other sites More sharing options...
erikjauli Posted March 19, 2009 Author Share Posted March 19, 2009 the .DS_Store file is a pretty common file on a mac, however it's a "hidden" file. i was under the impression that it was a necessary file that exists within folders so I was hesitant to manually delete it. From what ive researched its not vital and I should be able to manually delete it through terminal. I'll give that a try in the morning and see what happens Quote Link to comment https://forums.phpfreaks.com/topic/150058-solved-php-xml-generator-including-ds_store-file/#findComment-788157 Share on other sites More sharing options...
markjoe Posted March 19, 2009 Share Posted March 19, 2009 Yes, you can delete it, BUT, another one will be created when a Mac opens the folder again. Anytime you scan a directory for files, you should be excluding hidden files. Unless you are specifically looking for them anyway. $D = scandir($P); foreach($D as $F){ if($F{0} != '.'){ // do stuff here } } Quote Link to comment https://forums.phpfreaks.com/topic/150058-solved-php-xml-generator-including-ds_store-file/#findComment-788255 Share on other sites More sharing options...
erikjauli Posted March 20, 2009 Author Share Posted March 20, 2009 Thanks for the suggestion, for some reason that command wasn't working. I was however able to get it to work by using this: foreach ($dir as $file) { if ($dir->isDot()) {continue;} if (strripos($file,".jpg")==true) { That solved the problem by only including .jpg's in the xml which is exactly what im looking for. Thanks again. -Erik Quote Link to comment https://forums.phpfreaks.com/topic/150058-solved-php-xml-generator-including-ds_store-file/#findComment-789681 Share on other sites More sharing options...
markjoe Posted March 22, 2009 Share Posted March 22, 2009 Some small details: Are all these files under your control? can a file get in there with .jpeg? or other formats? Also, the ==true is redundant if(stripos($file,'.jpg')==true) is functionally identical to if(stripos($file,'.jpg')) that usage of strpos() will work fine, but strpos and stripos can be tricky, watch out for them in the future. (php.net is your friend) ...just a few general pointers Quote Link to comment https://forums.phpfreaks.com/topic/150058-solved-php-xml-generator-including-ds_store-file/#findComment-790676 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.