0
 if(isset($_POST['btn_upload']))
 {
     $filetmp = $_FILES['photo']['tmp_name'];
     $filename = $_FILES['photo']['name'];
     $filetype = $_FILES['photo']['type'];
     $filepath = "photo/".$filename;

     move_uploaded_file($filetmp,$filepath);
 }

in this code i am getting error as Undefined index: photo

here photo is the name of the input file tag which is in different html file

<div class="form-group">
<label class="col-md-4 control-label">Upload Image</label>
<div class="col-md-4 inputGroupContainer">
<span class="input-group-btn">
<span class="btn btn-default btn-file">
Browse… <input type="file" id="imgInp" name="photo">
</span>
</span>
</div>
<img id='img-upload' />
</div>

so i tried this

$_FILES['photo']=$_POST['photo'];

but then i got error

Illegal string offset 'tmp_name'

Illegal string offset 'name'

Illegal string offset 'type'

please help me out in this.

thanks in advance

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
anirudh
  • 53
  • 1
  • 10

1 Answers1

1

Your form should include enctype multipart/form-data

<form method="post" enctype="multipart/form-data" action="">
ADIN
  • 317
  • 3
  • 14