DB의 레코드에 대한 업데이트 양식을 만들려고합니다. 이 양식입니다 ('파일'을 제외한) 모든 입력 필드의
<form id="form_update_ad" method="post" action="inc/API.php" enctype="multipart/form-data">
<input type="text" name="input_publisher" id="input_publisher_edt" placeholder="Name" />
<input type="text" name="input_link" id="input_link_edt" placeholder="Link" />
<input type="file" name="file2Upload_edt" id="file2Upload_edt" />
<input type="submit" value="" id="btnUpdate" />
<input type="hidden" name="command" value="update_ad" />
<input type="hidden" value="" id="curr_image_filename" />
<input type="hidden" value="" id="curr_add_id" />
</form>
값 jQuery를 설정하고, 그들은 모두 올바르게, 내가 확인을 두 번 설정하고 있습니다. 새 이미지 파일이있는 경우 확인 :
$("#form_update_ad").on("submit", function(event){
event.preventDefault();
// some validations...
if(errors.length==0)
{
$(this).off("submit");
this.submit();
}
else
{
// if there are errors - do something here
}
});
은 내가이 API.php 파일에하고 싶은 것은 이것이다 : 다음
난 제출 버튼을 누르면 한 번 실행되는이 jQuery를 기능이 업로드되지 않은 경우 new_image_filename을 현재 파일 이름 (curr_image_filename
숨겨진 입력 필드에서 요청)에 설정하고, 예인 경우 서버에서 현재 설정된 파일을 삭제하고 새 이미지를 업로드 한 다음 new_image_filename을 해당 이름으로 설정하고 DB를 업데이트하십시오. 그래서 나는이 코드를 썼다 :
$newImageFileName = "";
if($_FILES["file2Upload_edt"]["name"]=='')
{
$newImageFileName = $_REQUEST["curr_image_filename"];
}
else
{
if(delete_file_from_server($_REQUEST["curr_image_filename"]))
{
$newImageFileName = saveImage2Server("file2Upload_edt");
update_ad($_REQUEST["curr_ad_id"],$_REQUEST["input_publisher"], $newImageFileName, $_REQUEST["input_link"]);
}
}
을하지만이 오류 메시지가 계속 해요 : 정의되지 않은 인덱스 : curr_image_filename를 MYPATH의 \의 API.php이입니다 라인 21에 : 왜 일어나고 $newImageFileName = $_REQUEST["curr_image_filename"];
어떻게 해결할 수 있습니까?
감사합니다. 나는 더 이상이'Undefined index' 메시지를 가지고 있지 않습니다! A는'update_ad()'함수에 대한 호출 배치에 또 다른 문제가 있다는 것을 알았습니다. (업로드 할 새 파일이 없다면 코드가 도달하지 않습니다.) 그래서 변경했습니다. 이제 PDO Update 쿼리에 몇 가지 문제가 있습니다. 조사해야 할 것입니다. 다시 한 번 도움을 주셔서 감사합니다. – Igal