HTML 폼에서 파일을 업로드하기 위해 PHP 스크립트를 실행하고 이름을 바꾸어 내 서버에 저장하십시오. 업로드하고 이름을 바꾸는 중이지만 모든 파일 이름은 이제 "Array"라는 단어로 시작됩니다.
예 : ArrayTest Document v1.0.pdf
테이블에 표시 할 때 그 문자가 내 $newfn
이 아닌 것으로 확신합니다. 그것이 move_uploaded_file
명령을 내 $FILES['uploaded']
섹션에 관련된 것처럼업로드 후 이름이 바뀐 파일 이름 앞에 ARRAY가 있습니다 - PHP
//This gets all the other information from the form
$name=$_POST['docname'];
$version=$_POST['docver'];
$date=$_POST['docdate'];
$type=$_POST['doctype'];
$author=$_POST['docauth'];
$file=$_FILES['uploaded']['name'];
//target directory is assigned
$target = $directory;
$target = $target . basename($file) ;
//grab file extension
$filetypes = array(
'image/png' => '.png',
'image/gif' => '.gif',
'image/jpeg' => '.jpg',
'image/bmp' => '.bmp',
'application/pdf' => '.pdf');
$ext = $filetypes[$_FILES['uploaded']['type']];
//generate new filename variable "name v??.xxx"
$newfn = $name . ' ' . 'v' . $version . $ext;
//Check to see if file exists
if (file_exists($directory . $file))
{
echo $_FILES["uploaded"]["name"] . " already exists. ";
}
else
{
//if its a new file, change name and upload
if (move_uploaded_file($_FILES["uploaded"]["tmp_name"],
$directory . $_FILES["uploaded"] . $newfn))
{
echo "The file ". basename($file). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
는 느낌. 검색 좀 해봤지만 "배열"이라고 말하면 Google 검색 결과는 원격으로 동일하지 않습니다.
좋아, 아래 덕분에 해결했습니다. 모든 이제 올바른 이름 구조 업로드
//if its a new file, change name and upload
if (move_uploaded_file($_FILES["uploaded"]["tmp_name"],
$directory . $newfn))
로 코드를 읽기 때문에 미래에 누군가를 위해 내가 전체 $_FILES
배열을 제거했습니다. 감사.
$ _FILES [ "uploaded"]이 (가) 배열이므로 showas 배열입니다. –