Tag: INF file BSP directory space Dex date root directory Models
Controller:(note namespace, mine is App/home)
<?PHPnamespace App\home\controller; UseApp\models\upload; UseThink\controller;classImageextendscontroller{ Public functionindex () {returnView (' Index/image '); } Public functionupload () {//get a form upload file such as 001.pdf uploaded $file= Request ()file(' Image '); //move to the Framework app root directory under the/public/uploads/directory $info=$file->validate ([' Size ' =>1567800, ' ext ' = ' pdf '])->move (Root_path. ' Public/static '. Ds. ' Uploads '); if($info){ //Upload message after successful upload//output PDF Echo $info-getextension (); //Output 2016.pdf Echo $info-Getsavename (); //output 42a.Pdf
Echo $info-GetFileName ();} Else // upload failed get error message echo$file-GetError ();}} }
View:
<!DOCTYPE HTML><HTML><Head> <MetaCharSet= "UTF-8"> <title>Zyy</title></Head><Body><formAction= "/home/image/upload"enctype= "Multipart/form-data"Method= "POST"><inputtype= "File"name= "image" /> <BR> <inputtype= "Submit"value= "Upload" /> </form> <!--PDF Display - <iframesrc= "__public__/uploads/20170324/ea7e83fee6a1094a33d712301ad14a46.pdf"frameborder= "0"scrolling= "No"ID= "External-frame"onload= "Setiframeheight (this)"style= "width:100%;height:1000px"></iframe></Body></HTML>
PHP pdf File Upload, display