I have a basic PHP script that accept a file send by the user. This code is just a simple API , the user is sending us file through POST request.
I was wondering how could I make this handle over 3000 users sending files at the same time? Do I need to use threading ? Whats the best solution?
On user website : (www.example.com)
<form action="http://www.mywebsite.com/file.php" method="post" enctype="multipart/form-data">
Your Photo: <input type="file" name="photo" size="25" />
<input type="submit" name="submit" value="Submit" />
</form>
Here is code on my server(mywebsite.com) (file.php):
//if they DID upload a file...
if($_REQUEST['photo']['name'])
{
//if no errors...
if(!$_REQUEST['photo']['error'])
{
//now is the time to modify the future file name and validate the file
$new_file_name = strtolower($_REQUEST['photo']['tmp_name']); //rename file
if($_REQUEST['photo']['size'] > (1024000)) //can't be larger than 1 MB
{
$valid_file = false;
$message = 'Oops! Your file\'s size is to large.';
}
//if the file has passed the test
if($valid_file)
{
//move it to where we want it to be
move_uploaded_file($_REQUEST['photo']['tmp_name'], 'uploads/'.$new_file_name);
$message = 'Congratulations! Your file was accepted.';
}
}
//if there is an error...
else
{
//set that to be the returned message
$message = 'Ooops! Your upload triggered the following error: '.$_REQUEST['photo']['error'];
}
}
Thanks in advance