HTML/PHP File Upload

I'm having problem with the uploading script.

Page 1 of 1

3 Replies - 666 Views - Last Post: 02 March 2010 - 12:34 PM Rate Topic: -----

#1 Guest_Syrillia*


Reputation:

HTML/PHP File Upload

Posted 02 March 2010 - 11:28 AM

I'm developing a website for a private group of people (hence the password), and I'm having a bit of trouble. Using this code:

		if ($_POST['form'] == "sent") {

			$pw = sha1($_POST['pw']);

			if ($pw == "1c882ecb4c9e6cf19a4ff207c7dbf8a250567fbf") {

				$target_path = "./";

				$target_path = $target_path . basename($_FILES['uploadedfile']['name']);

				if (($_FILES["file"]["size"] < 104857600) 
				&& ($_FILES['uploadedfile']['name']) != "index.php") {

					if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    						echo "The file " . basename($_FILES['uploadedfile']['name']) . " has been uploaded.";
					} else {
						echo "There was an error uploading the file, please try again!";
					}

				} else {
					echo "This file is too large!";
				}


			} else {
				echo "Incorrect Password!";
			}

		} else {

			echo "<form enctype='multipart/form-data' action='?page=upload' method='POST'>";
			echo "<input type='hidden' name='MAX_FILE_SIZE' value='104857600' />";
			echo "<input type='hidden' name='form' value='sent'>";
			echo "Choose a File to Upload (max 99mb):<br><br>";
			echo "<input name='uploadedfile' type='file' /><br><br>";
			echo "Password: <input type='text' name='pw'> * Double check this!<br><br>";
			echo "<input type='submit' value='Upload File' />";
			echo "</form>";

		}



With smaller files, it seems to work fine, but when I try to upload a larger one, I get this error:

"There was an error uploading the file, please try again!"

Any ideas?

Is This A Good Question/Topic? 0

Replies To: HTML/PHP File Upload

#2 Lang14  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 29
  • Joined: 15-August 09

Re: HTML/PHP File Upload

Posted 02 March 2010 - 11:41 AM

Hey Syrilla,

Do you know what operating system your server is run on? You could have read/write access issues for the folder you're trying to upload to.

You should CHMOD the folder you're uploading to '777'.

Hope that helps,
Lang14
Was This Post Helpful? 0
  • +
  • -

#3 Guest_Guest*


Reputation:

Re: HTML/PHP File Upload

Posted 02 March 2010 - 12:28 PM

I don't think it's because of permissions, because small files upload fine. Also, it's running on Red Hat Linux.
Was This Post Helpful? 0

#4 Aurel300  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 230
  • Joined: 10-November 07

Re: HTML/PHP File Upload

Posted 02 March 2010 - 12:34 PM

Um - php.ini or similar. It is pretty apparent it there is a file upload size limit, so check help on that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1