Warptweet Posted January 5, 2007 Share Posted January 5, 2007 Hi there, I have an upload form.When you upload a file, it obviously uploads.How can I make it so that it [b]also[/b] CREATES A .TXT FILE using the SAME name as the uploaded file, EXCEPT its a .txt file and not a .swf file?The name of the field in the browse file is uploadedfileThat would probably be like$_POST['uploadedfile'];to get it the name of the file. Quote Link to comment Share on other sites More sharing options...
dcro2 Posted January 5, 2007 Share Posted January 5, 2007 If you use fopen() with write access, the file will automatically be created.[code]<?php$o = fopen($_POST['uploadedfile'].".txt", "w");fclose($o);?>[/code]You can also strip the extension from the file to get just .txt, not .swf.txt Quote Link to comment Share on other sites More sharing options...
Warptweet Posted January 5, 2007 Author Share Posted January 5, 2007 Umm... just wondering....Does that CREATE [b]another[/b] file with the same name except for .txt?So in the end, I would have...XXX.swfandXX.txtboth files created? Quote Link to comment Share on other sites More sharing options...
Warptweet Posted January 5, 2007 Author Share Posted January 5, 2007 Sorry, I have another problem....www.warptweet.com/uploadflash.phpgo there, try uploading a flash file or something that you just 5-second doodled.It keeps saying "you may only upload flash files under 20MB", and i made sure I meet the requirements. Quote Link to comment Share on other sites More sharing options...
dcro2 Posted January 5, 2007 Share Posted January 5, 2007 Would you care to share some code?Also remember $_POST['uploadedfile'] contains the path, such as "C:\swffile.swf". Quote Link to comment Share on other sites More sharing options...
Warptweet Posted January 5, 2007 Author Share Posted January 5, 2007 I use this code for my uploader.[code]<?phpif (($_FILES["file"]["type"] == "application/x-shockwave-flash") &&($_FILES["file"]["size"] < 20480)) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; echo "Uploading " . $_FILES["file"]["name"]; echo " (" . $_FILES["file"]["type"] . ", "; echo ceil($_FILES["file"]["size"] / 1024) . " Kb).<br />"; if (file_exists("uploads/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; echo "Please delete the destination file and try again."; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]); echo "File has been stored in your uploads directory."; $o = fopen($_POST['uploadedfile'].".txt", "w"); $stringData = $_POST['flashname']; fwrite($o, $stringData); $stringData = $_POST['flashauthor']; fwrite($o, $stringData); fclose($o); }} else echo "Only flash files under 20MB may be uploaded.";?> [/code]What I'm trying to do is add extra forms to my uploader.Along with uploading the file, I want it to create an extra file with the same name as the uploaded file, except with a .txt extension, and in the .txt file I created, store the following...flashnameflashauthorflashdescription(the above were the names of the forms whom the person who entered in the form stored their Flash Name, the Author, and the Flash Description) Quote Link to comment Share on other sites More sharing options...
Warptweet Posted January 5, 2007 Author Share Posted January 5, 2007 Any help peoples? :( Quote Link to comment 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.