Reputation: 408
I have an error saying:
undefined index while uploading picture .
all other fields are getting but file type is not setting.
code below is page 1 where I posting the image
<form name="adduser" id="adduser" class="form-horizontal form-bordered" action="{$ROOT_OBJECT}/addpointtypetodo/save" enctype="multipart/form-data">
<div class="form-group">
<label class="col-sm-2 control-label">Point Type Tittle*</label>
<div class="col-sm-4">
<input type="text" class="form-control" placeholder="Name" name="addPointTypeTittle" id="addPointTypeTittle" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Point Type Subtitle*</label>
<div class="col-sm-4">
<input type="text" class="form-control" placeholder="Name" name="addPointTypeSubtitle" id="addPointTypeSubtitle" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Point Type Parse Tagline*</label>
<div class="col-sm-4">
<input type="text" class="form-control" placeholder="Name" name="addPointTypeTagline" id="addPointTypeTagline" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Point Type Icon URL</label>
<div class="col-sm-4">
<input type="file" class="form-control" placeholder="select file.." id="addPointTypeIcon" name="addPointTypeIcon">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Point Type Marker URL</label>
<div class="col-sm-4">
<input type="file" class="form-control" placeholder="select file.." id="addPointTypeMarker" name="addPointTypeMarker">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<input type="submit" class="btn btn-primary" name="addPointTypeSubmit" id="addPointTypeSubmit" value="Save">
</div>
</div>
</form>
and this is the page getting this image:
$uploadedFile = $_FILES['addPointTypeIcon']['tmp_name'];
$pointTypeIcon = 'images/category/' . $_FILES['addPointTypeIcon']['name'];
if (is_uploaded_file($uploadedFile))
{
$this->model->fields = array();
move_uploaded_file($uploadedFile, $pointTypeIcon);
array_push($this->model->fields, $pointTypeIndex);
array_push($this->model->fields, $pointTypeIcon);
$this->model->saveIcon();
}
// }
// if(isset($_FILES['addPointTypeMarker']))
// {
$uploadedFile = $_FILES['addPointTypeIcon']['tmp_name'];
$pointTypeIcon = 'images/marker/' . $_FILES['addPointTypeMarker']['name'];
if (is_uploaded_file($uploadedFile))
{
$this->model->fields = array();
move_uploaded_file($uploadedFile, $pointTypeIcon);
array_push($this->model->fields, $pointTypeIndex);
array_push($this->model->fields, $pointTypeIcon);
$this->model->saveMarker();
}
It saying images not set. please help.
Upvotes: 0
Views: 40
Reputation: 2022
You have to specify the post
method on the form
<form name="adduser" id="adduser" method="post" class="form-horizontal form-bordered" action="{$ROOT_OBJECT}/addpointtypetodo/save" enctype="multipart/form-data">
Files cannot be uploaded to PHP using the GET method, which is the default method for submitting forms.
Upvotes: 1