Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/46772-solved-removing-part-of-a-script/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.