assasinkilla Posted August 10, 2007 Share Posted August 10, 2007 Hello, i got a flashgallery, and for me to add pictures i must upload the pictures and modify the xml So any idea how to do this? The upload thing (for specials users only) and to modify the xml when it's uploaded, a place where to put text (that will be the name) that's part of the upload thing, and to make only upload picture format.. Ty Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/ Share on other sites More sharing options...
Fadion Posted August 10, 2007 Share Posted August 10, 2007 Uploading pictures is not that difficult. Im sure u can find a lot of tutorials out there. For the xml thing, if u want to just append data to the file's end, u can use fopen('file.xml', 'a') and fwrite('file.xml', $data). If u are going to modify nodes and stuff, then i dont know. Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-320801 Share on other sites More sharing options...
assasinkilla Posted August 10, 2007 Author Share Posted August 10, 2007 Sorry, im new and i need a better awnser... I want as soon as upload add something to the .xml. No offence or nothing, but i hate ppl that posts just to post, and im not telling anyone this... But can somebody help me with it pls Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-320807 Share on other sites More sharing options...
teng84 Posted August 10, 2007 Share Posted August 10, 2007 Uploading pictures is not that difficult. Im sure u can find a lot of tutorials out there. For the xml thing, if u want to just append data to the file's end, u can use fopen('file.xml', 'a') and fwrite('file.xml', $data). If u are going to modify nodes and stuff, then i dont know. maybe this post is right for more info look here http://www.php.net/manual/en/function.fwrite.php Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-320813 Share on other sites More sharing options...
teng84 Posted August 10, 2007 Share Posted August 10, 2007 or if that is hard for you you may try to use db something that will like cms system (not really) you will get all the data in your db to put in your xml i think that will be much easier for a nob Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-320818 Share on other sites More sharing options...
Fadion Posted August 10, 2007 Share Posted August 10, 2007 Ok i wrote u this file upload script <form enctype="multipart/form-data" action="" method="post"> <input type="file" name="pic" /> <input type="submit" value="Submit" name="Submit" /> </form> <?php if(strlen($_FILES['pic']['name']) > 1){ $file = basename($_FILES['pic']['name']); $ext = strtolower(substr(strrchr($file, '.'), 1)); $allowedExt = array('jpg', 'png', 'bmp', 'gif', 'tga', 'tif'); $uploadPath = "$file"; $size = $_FILES['pic']['size'] / 1024; // size in kb $maxSize = 1000; //size in kb if(in_array($ext, $allowedExt) and $size < $maxSize){ if(move_uploaded_file($_FILES['pic']['tmp_name'], $uploadPath)){ echo "The image $file was uploaded successfully"; } else{ echo "An error ocurred during upload. Try again later"; } } else{ echo "File format is unsupported or filesize is too big"; } } ?> For the xml part u can use: $file = 'yourFile.xml'; $data = 'some xml data'; $handle = fopen($file, 'a'); fwrite($handle, $data); fclose($handle); Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-320819 Share on other sites More sharing options...
corbin Posted August 10, 2007 Share Posted August 10, 2007 If you have to modify XML like in the middle of the file and you don't feel like getting crazy with regular expressions, you could use simplexml or something similar to parse it, add to it, then reconstruct the output file. Also, you probably don't want to do this, but I would suggest using a database if your image records are going to get large. That way, PHP could generate the XML file based off of a mysql database or something similar, making updating things much easier. (Depending on how often you update though, that way could be worse performance wise unless caching of some form was used.) Edit: Ahhhh..... Beat to it twice! Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-320821 Share on other sites More sharing options...
assasinkilla Posted August 11, 2007 Author Share Posted August 11, 2007 Well im kind of confused Well i will explain a litle how gallery works, i will attach the config.xml you will notice almost at the end are divided by sections, well i want people that choose the section, upload and when upload ads in the .xml the info example If to add a picture i need to copy this <img value="name.extension mp3="page-14.mp3" name="Page 13"></img> well to add when it's uploaded, looks kind of hard... Note: Auto writes the name in the image value attach: airservers.pirohost.com/ffa/config.xml thank you for all replies Best Regards Mudi Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-320829 Share on other sites More sharing options...
assasinkilla Posted August 11, 2007 Author Share Posted August 11, 2007 K, forget about that, how to order it by name? Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-321101 Share on other sites More sharing options...
JoeyT2007 Posted August 11, 2007 Share Posted August 11, 2007 There we go mudi: <form enctype="multipart/form-data" action="" method="post"> Song Artist: <input type="text" name="artist" /><br> Song Name: <input type="text" name="name" /><br> MP3 File: <input type="file" name="file" /><br> <input type="submit" value="Submit" name="Submit" /> </form> <?php if(strlen($_FILES['file']['name']) > 1) { $file = basename($_FILES['file']['name']); $name = $_POST['name']; $artist = $_POST['artist']; $ext = strtolower(substr(strrchr($file, '.'), 1)); $allowedExt = array('mp3'); $uploadPath = "musics"; if(!is_dir($uploadPath)) { mkdir($uploadPath,"0777"); } $uploadPath = $uploadPath."/".$file; $size = $_FILES['file']['size'] / 1024; // size in kb $maxSize = 10024; //size in kb if(in_array($ext, $allowedExt) and $size < $maxSize) { if (file_exists($uploadPath)) { echo "The file already exists!"; } else { if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadPath)) { echo "The mp3, $file was uploaded successfully and added to the playlist!"; $file = 'config.xml'; $handle = fopen($file, 'r'); $size=filesize($file); $size=$size-21; $contents = fread($handle, $size); $contents = $contents."#".$uploadPath.",".$artist." - ".$name."</play_list></config>"; fclose($handle); $file = 'config.xml'; $handle = fopen($file, 'w'); fwrite($handle, $contents); fclose($handle); } else { echo "An error ocurred during upload. Try again later"; } } } else { echo "File format is unsupported or filesize is too big"; } } ?> I have just started learning PHP so correct the mistakes but it works fine, no problems at all! Name!!! Holy crap, thats gonna take one hell of a script... Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-321124 Share on other sites More sharing options...
assasinkilla Posted August 11, 2007 Author Share Posted August 11, 2007 I get an error when uploading my music .mp3 around 4 mb An error ocurred during upload. Try again later Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-321141 Share on other sites More sharing options...
JoeyT2007 Posted August 15, 2007 Share Posted August 15, 2007 That would be a cap by your provider. Probably set to 2mb. Quote Link to comment https://forums.phpfreaks.com/topic/64337-when-you-upload-something-modify-text-in-the-xml-file/#findComment-324915 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.