Вот мой выстрел в это:
// Given: $file, $targetFilename, $photosPath, $maxSize
$filePath = NULL;
if (array_key_exists($_FILES, $file)
&& $_FILES[$file]['size'] != 0
&& $_FILES[$file]['error'] == UPLOAD_ERR_OK)
{
if ($_FILES[$file]['size'] > $maxSize)
{
throw new Exception("The uploaded photo was too large; the maximum size is $maxSize bytes.");
}
$imageData = getimagesize($_FILES[$file]['tmp_name']);
$extension = image_type_to_extension($imageData[2]);
if ($extension != ".jpg" && $extension != ".jpeg")
{
throw new Exception("Only .jpg photos are allowed.");
}
$possibleFilePath = $photosPath . $targetFilename . ".jpg";
if (!move_uploaded_file($_FILES[$file]['tmp_name'],
$_SERVER['DOCUMENT_ROOT'] . $possibleFilePath)
{
throw new Exception("Could not save the uploaded photo to the server.");
}
$filePath = $possibleFilePath;
}