끌어서 놓기 업 로더를 수정하려고합니다. 파일이 업로드되면 오른쪽에 표시됩니다. 오른쪽에 각 파일에 대한 설명 필드를 추가하고 싶습니다. 내 XML 디렉토리를 확인하여 작성되고 있습니다. 각 파일의 설명을 XML에 저장할 수 있습니다. 그러나 디렉토리에 파일을 제거하거나 업로드하는 경우 모든 설명을 "-
"으로 덮어 씁니다. 내가하려고하는 일은 이전 항목 설명을 덮어 쓰지 않고 새 항목을 업로드하거나 제거하는 것입니다.선택한 노드가 업데이트되지 않습니다.
PHP- 제거 및 업로드.이 함수는 업로드 된 각 파일에 대해 디렉토리를 확인하고 XML에 노드를 추가합니다. 각 항목에 대한 설명을 추가
if ($handle = opendir($path_to_image_dir))
{
while (false !== ($file = readdir($handle)))
{
if (is_file($path_to_image_dir.'/'.$file) && $file != "." && $file != ".." && $file != "Thumb.db" && $file != "Thumbs.db" && $file != ".DS_Store")
{
list($width, $height) = getimagesize($path_to_image_dir.'/'.$file);
$image = $xml_generator->addChild('image');
$image->addChild('id', 'file'.$i++);
$image->addChild('name', $file);
$image->addChild('width', $width);
$image->addChild('height', $height);
$image->addChild('description', '-');
}
}
closedir($handle);
}
// Write the XML File to a file.
$xml_generator->asXML('../file.xml');
Description.Php.
$filename = "../file.xml";
//value form the pop up description form.
$description = $_POST['description'];
// id of input from the write rightside list.
$hid = $_POST['fileID'];
$xml->image ->description = $description;
$xml = simplexml_load_file($filename);
foreach($xml->image as $image)
{
// matching the xml id to input id, and then updating the description.
if ($image->id == $fileID)
{
$image->description = $description;
}
}
$xml->asXML($filename);
내가 먼저 당신이, 당신의 Description.Php
로 3 문제를 볼 수 있습니다
<images>
<image>
<id>file0</id>
<name>image1.jpg</name>
<height>1435</height>
<width>2551</width>
<description>-</description>
</image>
<image>
<id>file1</id>
<name>Image2.jpg</name>
<height>1435</height>
<width>2551</width>
<description>-</description>
</image>
</images>
'echo $ image-> id;'와'echo $ description;'는 ** Description.Php **로 무엇을 제공합니까? 그들은 표시합니까? --- 질문에있는 코드가 잘못 보이지 않기 때문에 묻는 중입니다. 예제를 압축 할 수 있다면 파일 상호 작용없이 간단히 실행하면 문제를 개선하는 데 도움이됩니다. 결국 그것은 XML에 관한 것이지 파일 업로드가 아니기 때문에 제목을 사용하면 일부 사용자가 이탈 할 수도 있습니다. – hakre
echo $ image-> id; 그리고 echo $ description; 나를 위해 콘솔 로그에 아약스 요청에 값을 잡아입니다. 그것들은 무시할 수 있습니다. 그것은 실제로 아무 것도하지 않습니다. 미안해, 너를 혼란스럽게 할거야. 너는 제목과 질문에 대해 옳을 수도있다. 감사! – Tierendu
@Prix file0은 내 HTML 입력의 ID입니다. 그 다음 xml id-> file0과 일치시킵니다. 따라서 xml의 유일한 file0 섹션을 업데이트합니다. 이 부분은 이미 나를 위해 작동합니다. – Tierendu