2

私はここで他の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の「よくある落とし穴」の記事を調べましたが、何も修正されませんでした。誰かが何が悪いのか見たり、私にいくつかのヒントを教えてもらえますか?

4

2 に答える 2

1

次のヒントが役立ちます。

1. The folder exists, check for spellings
2. Check the properties of the folder and make sure the permissions have read+write 0666
3. Make sure the file is within your public html root, otherwise double check the owner of the file, and make sure PHP Has read / write access to it.
4. Look for the logs i.e. Unable to move '/tmp/php6wlOg1' to 'upload/110216104651_00134_smooth_1440x900.jpg'
5. If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. So set it according to your need.

また、これを設定して、エラーがあるかどうかを確認します

error_reporting(E_ALL); // or E_STRICT
ini_set("display_errors",1);
ini_set("memory_limit","1024M");
于 2012-05-19T22:16:12.197 に答える
0

ホスティングプロバイダーの技術者と何度もやり取りした後、彼らはフォルダーに適切なアクセス許可を与えることができました(私は以前に0777を試しましたが、機能しませんでした)。いくつかのブードゥーが舞台裏で起こったと思いますが、これはそうですNo errors in the error_log; I have set 777 permissions on /home/x/up、そしてスクリプトは働き始めました。

于 2012-05-20T00:50:44.377 に答える