Cheeseweasel Posted April 12, 2007 Share Posted April 12, 2007 Hello. Sorry the title's not too specific! Alright, I acquired a script the other day which I'd actually been looking for for quite a while - it's a script which allows the quick and easy upload of files from a user's computer to my website, in a special directory called 'host'. The annoying thing is, this quote changes the names of the files and their extensions. I'd like it to be a universal file uploader, but the thing is, it always (tries to) converts anything to .jpg extension. I've dubbed it an 'image uploader', but I'd like to make it a universal file uploader as I said. I'd be grateful if somebody could alter it a little bit so any file type can be uploaded and they retain their original filenames as well. (If possible, I'd also like it if a code could be added that disables the upload of files called 'index.html' or 'index.php', but that might be pushing my luck!). Here's the code. <?php if ($_REQUEST[completed] == 1) { $newname = uniqid("img").".jpg"; move_uploaded_file($_FILES['mailfile']['tmp_name'], "$newname"); } ?> <html> <head><title>Scrawlings of a Host</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> <!-- body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #FFFFFF; } .style2 { font-style: italic; font-size: 24px; font-weight: bold; } body { background-color: #3399FF; } a:link { color: #FFFFFF; } a:visited { color: #FFFFFF; } a:hover { color: #FF0000; } a:active { color: #FFFFFF; } .style10 {font-weight: bold} --> </style></head> <body> <h1 align="center" class="style2">Cheeseweasel's Image Hosting Service </h1> <p align="center"><strong> <?php if ($_REQUEST[completed] != 1) { ?> Please upload an image by telling me the directory of the image and clicking 'submit'.</strong></p> <p align="center">Please note; any image can be uploaded, this uploader changes them to .jpg format. However, other files (non-pictures) will not work with this uploader. If you wish for another file format to be uploaded, please ask Cheeseweasel and he'll upload it just for you. </p> <form method=post enctype=multipart/form-data> <div align="center"><strong> <input type=hidden name=MAX_FILE_SIZE value=1500000> <input type=hidden name=completed value=1> Choose file to send: <input type=file name=mailfile> <input type=submit> </strong> </div> </form> <div align="center"> <p><strong> <?php } else { ?> Thanks for uploading! Please <a href="show.php">click here</a> to see your uploaded file. Clicking the link will give you a list of uploaded files, all converted to JPG, and their filenames randomised. Just find your one (it should be at the top) and just use its URL for whatever purposes you desire. </strong><strong> <?php } ?> </strong> </p> </div> <hr align="center"> <div align="center" class="style10"> <p align="center">This script ain't mine, so don't go thinking I made it.<br> However, please don't abuse it. If when browsing through the files, you notice something unsuitable, please click the following link to report it.<br> <br> <a href="mailto:cheeseweasel@scrawlingsofacheese.co.uk">Report abuse<br> </a><a href="http://www.scrawlingsofacheese.co.uk/host/upload.php">Refresh Page (For when you have uploaded a file) </a></p> </div> </body></html> Thank you for your help and I eagerly await response. -Cheeseweasel Quote Link to comment https://forums.phpfreaks.com/topic/46772-solved-removing-part-of-a-script/ Share on other sites More sharing options...
MadTechie Posted April 12, 2007 Share Posted April 12, 2007 you can use the one from here but your missing a file on the code below Quote Link to comment https://forums.phpfreaks.com/topic/46772-solved-removing-part-of-a-script/#findComment-227973 Share on other sites More sharing options...
Cheeseweasel Posted April 12, 2007 Author Share Posted April 12, 2007 I love the one I've got, though. I just want a few bits removed from it. It's simple and it works. All I want is just for it to stop renaming and converting files to .JPG. I'm fine with everything else it does. Quote Link to comment https://forums.phpfreaks.com/topic/46772-solved-removing-part-of-a-script/#findComment-227978 Share on other sites More sharing options...
Cheeseweasel Posted April 12, 2007 Author Share Posted April 12, 2007 Uhmm, anybody there? I need this quite urgently. Quote Link to comment https://forums.phpfreaks.com/topic/46772-solved-removing-part-of-a-script/#findComment-227988 Share on other sites More sharing options...
MadTechie Posted April 12, 2007 Share Posted April 12, 2007 but your missing a file on the code below Quote Link to comment https://forums.phpfreaks.com/topic/46772-solved-removing-part-of-a-script/#findComment-227991 Share on other sites More sharing options...
Cheeseweasel Posted April 12, 2007 Author Share Posted April 12, 2007 I don't understand what you mean. If you're referring to show.php; I created that file, I didn't think I needed to show it to you, it's unrelated to this upload form. Quote Link to comment https://forums.phpfreaks.com/topic/46772-solved-removing-part-of-a-script/#findComment-227993 Share on other sites More sharing options...
MadTechie Posted April 12, 2007 Share Posted April 12, 2007 well as a guess you could try $newname = $_FILES['mailfile']['name']; Quote Link to comment https://forums.phpfreaks.com/topic/46772-solved-removing-part-of-a-script/#findComment-227999 Share on other sites More sharing options...
Cheeseweasel Posted April 12, 2007 Author Share Posted April 12, 2007 What, rather than $newname = uniqid("img").".jpg"; ? Quote Link to comment https://forums.phpfreaks.com/topic/46772-solved-removing-part-of-a-script/#findComment-228000 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.