저는 PHP에 대해 많이 알지 못합니다. 하지만 어쨌든 다음의 PHP를 사용하여 .csv 파일을 업로드 할 수 없습니다. upload_max 크기 관련 속성으로 문제를 해결했습니다. 내 로컬에서는 제대로 작동하지만 샌드 박스에서는 작동하지 않습니다. 파일 유형 문제입니까?Apache에서 업로드 오류가 발생했습니다.
나는 다음과 같이 인쇄 할 수 있습니다. 이것은 전혀 도움이되지 않습니다. "-로드 할 CSV 파일 : > > > 유효하지 않은 파일 : 1"
여기서 수정해야 할 부분은 무엇입니까? 정확히 "1"값 대신 완전한 PHP 오류 메시지를 인쇄하려면 어떻게해야합니까? 즉 ... "UPLOAD_ERR_INI_SIZE : 1"과 같이 더 유용한 출력물을 출력 하시겠습니까?
<?php
// using upload at click from http://code.google.com/p/upload-at-click/
// FileData is the name for the input file
$file_result = "";
$file = $_FILES['Filedata'];
$allowedExtensions = array("csv", "txt");
$arrayVar = explode(".", $file["name"]);
$extension = end($arrayVar);
//commented out for “Only variables should be passed by reference” error
//$extension = end(explode(".", $file["name"]));
function isAllowedExtension($fileName) {
global $allowedExtensions;
return in_array(end(explode(".", $fileName)), $allowedExtensions);
}
if($file["error"] > 0){
echo "failure to upload the file >>> ". "Error code: ".$file["error"]."<br>";
}else{
//echo " >>> CURRENT DIR: ".getcwd() . "\n";
$workDir = getcwd();
$dir = substr($workDir, 0, -10);
$path = $file["name"];
$newFileLoc = $dir.$path;
$file_result.=
"<br> Upload: " . $file["name"] . "<br>" .
" Type: " . $file["type"] . "<br>" .
" Size: " . $file["size"] . "<br>" .
" file uploaded to: ".$newFileLoc."<br>";
// txt - text/plain
// rtf - application/msword
// dat/obj - application/octet-stream
// csv - application/vnd.ms-excel
// maximum 200 MB file - 200,000,000 k
if ( ($file["type"] == "application/vnd.ms-excel" || $file["type"] == "text/plain")
&& isAllowedExtension($file["name"])
&& ($file["size"] < 200000000)
)
{
move_uploaded_file($file["tmp_name"], $newFileLoc);
//echo $file_result.=" >>> File uploaded successfull!!";
echo "|".$path;//"filePath : " . $newFileLoc;
}else{
echo " >>> NOT a file valid: ". isAllowedExtension($file["name"]);
}
}
?>
이 오류는 다른 사용자가 오류를 올바르게 catch하기 위해 추가 한 행입니다. 그게 옳은지 제가 PHP를 많이 알지 못한다면 알려주십시오. 어쨌든, 인쇄 오류가 그냥 "- 부하에 CSV 파일 : > > > 유효하지 않은 파일 : 1"
<?php
// using upload at click from http://code.google.com/p/upload-at-click/
// FileData is the name for the input file
ini_set('display_errors', 1); error_reporting(E_ALL);
$file_result = "";
$file = $_FILES['Filedata'];
$allowedExtensions = array("csv", "txt");
$arrayVar = explode(".", $file["name"]);
$extension = end($arrayVar);
감사합니다. 감사합니다. 나는 당신의 제안에 따라 PHP를 업데이 트했습니다. 이 방법은 훨씬 더 명확합니다. 하지만 이제는 새로운 오류가 발생합니다 "-로드 할 CSV 파일 : 잘못된 유형 : application/octet-stream" – user1518600