ブラウザを介して一度に大量の画像 (たとえば 200 個の小さな画像) をアップロードする必要があります。私はこのコードを持っています:
<?php
if(isset($_POST['Upload_files']) and $_SERVER['REQUEST_METHOD'] == "POST"){
echo count($_FILES['files']['name']); // Even if I upload more than 20 files, it still displays 20.
$target_directory = "upload/";
foreach ($_FILES['files']['name'] as $file_number => $file_name) {
$file = $_FILES["files"]["tmp_name"][$file_number];
if (mime_content_type($file) != 'image/png' && mime_content_type($file) != 'image/jpeg')
{ $error[] = 'File '.$file_name.' is not in JPG / PNG format!'; continue; }
else
{ if(move_uploaded_file($file, $target_directory.$file_name)) {$count_of_upload_file++;}}
}
}
// If files were uploaded
if($count_of_upload_file != 0){echo 'Your files ('.$count_of_upload_file.' ) were successfully uploaded.';}
// If there was an error
if (isset($error)) {foreach ($error as $display_error) {echo '- '.$display_error.'<br />';}}
?>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="files[]" multiple="multiple" accept="image/*">
<input type="submit" name="Upload_files" value="Upload files">
</form>
そして、それは機能します。ただし、私のプロバイダーは「max_file_uploads」を 20 に設定しました (変更できません)。(Uploadify 拡張機能は 20 個以上のファイルに対して機能していますが、私は独自の小さなソリューションが必要です。) したがって、ここに何かを追加する必要があると思います。これは、200 個のファイルを一度にアップロードする代わりに、200 個のファイルを 1 つずつアップロードします (または20×20)。しかし、私はそれを行う方法がわかりません。(AJAX を使用するには? -- 使用したことがないので、よくわかりません。) ありがとうございます。