I have a form which contains a file input:
var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='startImageUpload(this);' class='imageuploadform' ><label>" +
"Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><label class='imagelbl'>" +
"<input type='submit' name='submitImageBtn' class='sbtn' value='Upload' /></label>" + +
"</p> <iframe class='upload_target' name='upload_target' src='#' style='wclassth:0;height:0;border:0px;solclass #fff;'></iframe></form>");
This links to a php script where it uploads the file:
<?php
$destination_path = str_replace("//", "/", $_SERVER['DOCUMENT_ROOT']."/")."ImageFiles";
$result = 0;
$target_path = $destination_path . basename( $_FILES['fileImage']['name']);
if(move_uploaded_file($_FILES['fileImage']['tmp_name'], $target_path)) {
$result = 1;
}
sleep(1);
?>
<script language="javascript" type="text/javascript">window.top.window.stopImageUpload(<?php echo $result; ?>);</script>
Problem is that in the php script it is stating I am having an undefined index wherever it states 'fileImage' in the php script. But I don't know why it is saying I am having undefined index when I have mentioned in the name attribute in the form 'fileImage'. Why is it stating I am having an undefined index for 'fileImage' in the php script?
Here is a link to an application where you can append rows which include file inputs, you can test this and see for yourself if you wish but at moment it keeps saying there is an error during uploading. application
There can be many reasons that are the root-cause of this error, but the actual reason is, that the
$_FILES
array has no string index'fileImage'
.To get a better view which indexes are available, you can do a:
See as well
array_keys
andvar_dump
.Probably the following (in this question undocumented javascript code) is destroying something in your form or it's data: