HTML code
<include file= "./application/home/view/default/public/homeheader.html"/>functionChangemouse ()//mouse over to change to hand shape {varObj1 = document.getElementById ("Changemouse1");varObj2 = document.getElementById ("Changemouse2"); Obj1.style.cursor = ' pointer '; Obj2.style.cursor = ' pointer '; }</script><script>functionDefaultmouse ()//mouse back, reply to default {varObj1 = document.getElementById ("Changemouse1");varObj2 = document.getElementById ("Changemouse2"); Obj1.style.cursor = ' default '; Obj2.style.cursor = ' default '; }</script><!--<script> function display () {var obj = document.getElementById ("demo") { Obj.style.display= ""; }}</script>!--><script>functionCheck1 ()//Check the picture format {varFilepath=file1.value; Filepath=filepath.substring (Filepath.lastindexof ('. ') +1,filepath.length);if(filepath! = ' jpg ' && filepath! = ' gif ' && filepath! = ' png ' && filepath! = ' jpeg ') alert ("Upload only images in jpg,gif,png or JPEG format");Elsedocument.getElementById ("F1name"). Innertext=file1.value; }</script><script>functionCheck2 () {varFilepath=file2.value; Filepath=filepath.substring (Filepath.lastindexof ('. ') +1,filepath.length);if(filepath! = ' jpg ' && filepath! = ' gif ' && filepath! = ' png ' && filepath! = ' jpeg ') alert ("Upload only images in jpg,gif,png or JPEG format");Elsedocument.getElementById ("F2name"). Innertext=file2.value; }</script></body>PHP code
Public functionUpload () {if(isset($_post[' submit ')) {Import (' Think.Verify.Upload '); $imagea = new Image (); $picture =NewUpload (); Instantiate upload class $picture->maxsize = 3145728;//Set attachment upload size $picture->exts =Array(' jpg ', ' gif ', ' PNG ', ' jpeg ');//Set attachment upload type $picture->rootpath = './uploads/';//Set attachments to upload the root directory $picture->sav Epath = "; Set attachments Upload (sub) directory $info = $picture->upload ();//Upload fileif(! ($info [' file1 ']&& $info [' file2 ']) {Echo"<script>alert (' please upload file ') </script>"; }//$fr = './uploads/'; Error http://localhost/use/index.php/home/user/Uploads/2016-11-14/5829803394673.jpg//$fr = ' uploads/'; Error http://localhost/use/index.php/home/user/Uploads/2016-11-14/582980519743a.jpg//$fr = '/uploads/'; Error http://localhost/Uploads/2016-11-14/5829807535c04.jpg $FR = '/user/uploads/';//correct Http://localhost/user/Upload S/2016-11-14/582963ff2640f.jpg//$ADDR 1 = $fr. $info [' file1 '] [' Savepath ']. $info [' file1 '] [' savename ']; $addr 2 = $fr. $info [' file2 '] [' Savepath ']. $info [' file2 '] [' savename ']; $user = M (' user_admin ');//Instantiate the User object//change the value of certificate_address and contract_address for the users $upload _role_id_address =Array(' certificate_address ' = $fr. $info [' file2 '] [' Savepath ']. $info [' file2 '] [' savename '], ' contract_address ' = $ Fr. $info [' file1 '] [' Savepath ']. $info [' file1 '] [' savename ']); $name = $_session[' Adminid '];//get the SESSION account name $_session[' Adminid '],$_session[' pwd '],$_session[' Loginkey '], $where [' Admin '] = $name;//$user->where ($where)->setfield ($upload _role_id_address) for judging conditions; $addr 1 = $upload _role_id_address[' contract_address '); $addr 2 = $upload _role_id_address[' certificate_address '); $this->assign (' Addr1 ', $addr 1); $this->assign (' ADDR2 ', $addr 2); echo "New\think\image (); $image 2 =New\think\image (); $image 1->open ('./uploads/'. $info [' file1 '] [' Savepath ']. $info [' file1 '] [' savename ']); $image 2->open ('./uploads/'. $info [' file2 '] [' Savepath ']. $info [' file2 '] [' savename ']); $image 1->thumb (600,\think\image::image_thumb_fixed)->save ('./uploads/contract.jpg ');//fixed thumbnail $image 2->thumb (600,\think\image::image_thumb_fixed)->save ('./uploads/certificate.jpg ');//fixed thumbnail//$image 1->thumb (->save) ('./uploads/contract.jpg ') ; Proportionally scaled//$image 2->thumb (->save) ('./uploads/certificate.jpg ');Echo"<script>alert (' Information upload success ') </script>"; $addr 1= $fr. ' Contract.jpg '; $addr 2= $fr. ' Certificate.jpg '; /* echo "<div class=\" Form-group\ "style=\" float:right\ ">//file preview feature <div><strong> file preview: </s trong></div> <table> <tr> <td> <td></td> </tr> </tabl E> </div> ";//Show Contract *///echo" ";//Show ID $this->assign (' Addr1 ', $addr 1); $this->assign (' ADDR2 ', $addr 2); } $this->display ();} Modify
Also create a upload folder in the current folder, or you can not upload pictures.
http://blog.csdn.net/s371795639/article/details/53410697
Upload file Click to show Picture