paul pote
paul pote

Reputation: 99

php error when uploading at the same time

I have a very simple upload function that receives data (a picture) form a $FILES - it works fine when uploading from times to times. However, if I increase the charge and send quickly a lot of files, it crashes (I don't even get error msg...)

Obviously, it's not a problem of uploading multiples files here - files may be uploaded by different users...

in the index.php, I have :

switch ($_POST['command']) {    
case "testWrite":
testWrite($_FILES['picture']);
break;

Then the function is:

function testWrite($data){
    $filename=....;
    if ($data['error']==0) {
        if (move_uploaded_file($data['tmp_name'], $filename)) {

        } else {

        };
    }
}

What am I missing?

Upvotes: 0

Views: 52

Answers (1)

Jens A. Koch
Jens A. Koch

Reputation: 41776

You might check and raise the php.ini settings for max_file_uploads and memory_limit. The last setting is not so obvious but also affects file uploading.

Enable error reporting:

error_reporting(E_ALL);
ini_set('display_errors', 1); 

In your else section you might dump the error:

else {
    echo 'File upload error: ' . $_FILES[0]['error'];
    // or maybe var_dump($_FILES); to see it all
}

Upvotes: 1

Related Questions