私はここで他の5つの同様の質問を調べましたが、どれも私の問題を解決できませんでした。サイズが1657バイトのCSVファイルをアップロードしています。
これが私のphp.iniファイルからのいくつかの値です
upload_max_filesize = 2M
post_max_size = 8M
$file = $_FILES['csv'];
if (!isset($file)) {
halt(HTTP_NOT_FOUND, 'This page could not be found on the web server');
}
if (substr(strrchr($file['name'], '.'), 1) != 'csv') {
halt(500, 'Sorry but please upload a CSV file next time!');
}
if ($file['error'] != '0') {
die('An error occurred during upload.<br />Error: ' . $file['error']);
}
$file_loc = '/home/x/tmp/up/' . basename($file['tmp_name']) . '.csv';
if (file_exists('/home/x/tmp/up/')) {
echo 'the directory exists....<br/>';
}
if (file_exists($file['tmp_name'])) {
echo 'tmp file exists<br/>';
echo filesize($file['tmp_name']) . 'b<br/>';
}
if (move_uploaded_file($file['tmp_name'], $file_loc)) {
echo 'Uploaded to: ' . $file_loc;
} else {
echo 'something went wrong!' . print_r($_FILES['csv'], true);
echo '<br />Upload Max Size: ' . ini_get('upload_max_filesize');
echo '<br />POST Max Size: ' . ini_get('post_max_size');
}
そして、ファイルをアップロードしたときに生成される出力は次のとおりです。
the directory exists....
tmp file exists
1657b
something went wrong!Array ( [name] => hm.csv [type] => application/vnd.ms-excel [tmp_name] => /tmp/php72p1VP [error] => 0 [size] => 1657 )
Upload Max Size: 2M
POST Max Size: 8M
私はすでにPHP.netの「よくある落とし穴」の記事を調べましたが、何も修正されませんでした。誰かが何が悪いのか見たり、私にいくつかのヒントを教えてもらえますか?