Rogue Modder Posted August 19, 2009 Report Posted August 19, 2009 Guys, i need a php upload script, thats simple to use/install. It can upload any file size, i can manage extensions (some sort of .ini). And when uploaded it shows a link to the file. Thanks. 1
iBotPeaches Posted August 20, 2009 Report Posted August 20, 2009 upload.php<?php // Configuration $allowed_filetypes = array('.rar','.zip','.sppf','.ppf','.serenity','.txt', '.png','.jpg', '.bmp'); $max_filesize = 1310720; $upload_path = './files/'; $filename = $_FILES['userfile']['name']; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large, our limit is 10MB.'); if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); // Upload the file to your specified path. if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '" title="Your File">here</a>'; else echo 'There was an error during the file upload. Please try again.'; // It failed . ?> Page with upload (Like index.html) <form action="./upload.php" method="post" enctype="multipart/form-data"> <label for="file"></label> <div align="center"><input name="userfile" id="file" type="file" /> <br /> <button>Upload File</button> The most basic there is.
Dark Slipstream Posted August 21, 2009 Report Posted August 21, 2009 (edited) $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); Simple question, but without actually testing this code, I beleive this will return anything from the first instance of a period to the end of the filename. Edit: Confirmed, yes it will. Simple fix, use strrpos instead of strpos. Edited August 21, 2009 by Dark Slipstream
iBotPeaches Posted August 21, 2009 Report Posted August 21, 2009 I've been using that exact script on iBotFiles forever and had no problems, so don't entirely know what the problem is.If its not broken, why fix it lol?
Rogue Modder Posted August 21, 2009 Author Report Posted August 21, 2009 (edited) Peaches you know iBotFiles.com loops after 5MB. You have to edit the php.ini file to allow http uploads over 5MB. Example: http://ibotmodz.rogue-mods.com/upload/ Edited August 21, 2009 by Dakote
Dark Slipstream Posted August 21, 2009 Report Posted August 21, 2009 Well strpos returns the first occurrence of the period in the filename. strrpos returns the last occurrence. Basically, if I went to upload IP.Board3.psd, the file extension would be returned as .Board3.psd.
Rogue Modder Posted August 21, 2009 Author Report Posted August 21, 2009 No, it doesn't for me. i have uploaded 2 films, 2 albums and 5 apps, all of them came out as .rar.
iBotPeaches Posted August 22, 2009 Report Posted August 22, 2009 iBotFiles is my tiny upload area. I'm not going to mess with its source, it works the way it is and thats fine with me. My php.ini is maxed at 5MB of which my hoster limits, it just loops if larger because of a php timeout.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now