Sunday 15 April 2012

php - HTML5 accept attribute for image uploader - get value through POST -



php - HTML5 accept attribute for image uploader - get value through POST -

i've been trying find out how utilise html5 file type accept attribute have been struggling find details best way utilize it.

at nowadays can understand gets name of file. how data? how store on server?

<input type="file" id="feature" name="feature" accept="image/*">

this php after post submission:

$pic = $_post["feature"]; echo $pic; // outputs filename

the post value of file input ever show filename. file uploaded temp file. it's move want move_uploaded_file()

http://php.net/manual/en/function.move-uploaded-file.php

from manual:

$tmp_name = $_files["feature"]["tmp_name"]; //the temporary file $name = $_files["feature"]["name"]; // it's name move_uploaded_file($tmp_name, "$uploads_dir/$name"); //put there

when working files, utilize $_files not $_post

important

none of work if not add together enctype attribute upload form.

<form ... enctype="multipart/form-data">

php html5 file-upload image-uploading

No comments:

Post a Comment