Jump to content

[SOLVED] File Upload Function Not Working


Jukebox42

Recommended Posts

I have a function that uploads a file onto the server but it doesn't work. It always returns "There was an error processing your request, please try again." Can anyone tell me why it might not work?

 

Thanks in advance,

Juke

 

Function listed below:

//upload post function
	function uploadPost()
	{
		$loc = $_POST['loc'];
		if( move_uploaded_file( $_FILES['fileUp']['tmp_name'], "uploads/$loc/".basename($_FILES['fileUp']['name']) ) )
		{
			$this->message2 = "File uploaded.";
		}
		else
		{
			switch( $_FILES['fileUp']['error'] )
			{
				case 1:
				case 2:
					$this->message2 = "Your file could not be uploaded because:<br>The file has exceeded the maximum file size limit.";
					break;
				case 3:
					$this->message2 = "Your file could not be uploaded because:<br>The file was only partially uploaded.";
					break;
				case 4:
					$this->message2 = "Your file could not be uploaded because:<br>The File was not uploaded.";
					break;
				case 5:
					$this->message2 = "Your file could not be uploaded because:<br>An unknown error occured.";
					break;
				default:
					$this->message2 = "There was an error processing your request, please try again.";
					break;
			}
			$this->message2 .= "<br>The file ".  basename( $_FILES['fileUp']['name'])." has been uploaded";
		}
	}

Link to comment
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.