Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > พรีวิวรูปภาพก่อนอัพโหลด ครับ ใช้ได้ครับ แต่...ติดตรงที่เอามาอยู่ในเทมเพลตคลาส



 

พรีวิวรูปภาพก่อนอัพโหลด ครับ ใช้ได้ครับ แต่...ติดตรงที่เอามาอยู่ในเทมเพลตคลาส

 



Topic : 091993



โพสกระทู้ ( 1,008 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter Facebook



พรีวิวรูปภาพก่อนอัพโหลด ครับ ใช้ได้ครับ แต่...

---
form_upload.html
-----
Code (PHP)
<html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
<script language="javascript">
function show_pic(sc){
	document.form1.action="php_upload.php";
	document.form1.target='mypre';
	document.form1.submit();	
}
</script>
</head>

<body>

<span id="mypic1"></span>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="">
<input type="text" name="textData" id="textData" />
<br />
<input type="file" name="pic" onchange="show_pic(this.value);" />
  <input type="submit" name="Submit" value="Submit" />
</form>
<iframe name="mypre" width="0" height="1" frameborder="0"></iframe>
</body>
</html>


---------
php_upload.php
--------------

Code (PHP)
<?php  
function upimg($img,$imglocate){  
            global $file_up;  
            if($img['name']!=''){  
            $fileupload1=$img['tmp_name'];  
            $g_img=explode(".",$img['name']);  
            $file_up=time().".".$g_img[1];  
                if($fileupload1){  
                    $array_last=explode(".",$file_up);  
                    $c=count($array_last)-1;  
                    $lastname=strtolower($array_last[$c]);  
                    if($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg" or $lastname=="swf"){                    
                        @copy($fileupload1,$imglocate.$file_up);              
                    }     
                }                 
            }  
}  
if($_FILES['pic']['name']!=""){  
    upimg($_FILES['pic'],"temp/");  
    echo "<script language=\"javascript\">";  
    echo "var pl=top.document.getElementById('mypic1');";  
    echo "pl.innerHTML=\"<img src='temp/".$file_up."' width='50' height='50' />\";";  
    echo "top.document.form1.action='';";  
    echo "top.document.form1.target='';";  
    echo "</script>";  
   // echo "<meta http-equiv=\"Refresh\" content=\"0;URL=127.0.1/testweb/php_upload.php?d_img=".$file_up."\" />"; 
	
}else{ echo "eeree";}
?>  
<?php  
    if($_GET['d_img']!=""){  
	echo $_GET['d_img'];
        @unlink("temp/".$_GET['d_img']);  
    }  
		
?>  

มันทำงานได้ ตามปกติ แต่ผมต้องการย้าย มาอยู่ในส่วนของเทมเพลต ที่มี ลักษณะ

----
structure.html
-----

Code (PHP)
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="include/stly.css">
<script language="javascript">
		
<script language="javascript">
function show_pic(sc){
	
	document.form1.action='admin.php';
	document.form1.target='mypre';
	document.form1.submit();	
}
</script>

</head>
<body> 
<div id="header"> 
##TOP##</div> 
<div id="wrapper"> 
		<div class="content-left"> ##LEFT##	</div> 
	    <div class="content"> ##CONTENT##</div>
		<div class="content-right"> ##RIGHT##</div>
</div> 
<div id="footer"> ##FOOTER##</div> 

</body>
</html>

---------------------
formmember.html
----------------------

Code (PHP)
<span id="mypic1"></span>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="">
<input type="text" name="textData" id="textData" />
<br />
<input type="file" name="pic" onchange="show_pic(this.value);" />
  <input type="submit" name="Submit" value="Submit" />
</form>
<iframe name="mypre" width="0" height="1" frameborder="0"></iframe>

----------------------
formmember.php
----------------------

Code (PHP)
<?php 
include_once("./include/class.rFastTemplate.php");
$url1="../template/structure.html";
$url2="../template/formmember.html";
$url3="../template/top.html";
$url4="../template/left.html";
$url5="../template/rigth.html";
$url6="../template/footer.html";
$url7="../template/view.html";
//--------------
$tpl = new rFastTemplate("template");
$tpl->define (array("main_tpl"=>$url1,"detail_tpl"=>$url2,"top_tpl"=>$url3,"left_tpl"=>$url4,"rigth_tpl"=>$url5,"footer_tpl"=>$url6,"view_tpl"=>$url7));
//-------------


//--content

	
//--------------end content
$tpl->parse("##TOP##","top_tpl");
$tpl->parse("##CONTENT##","content_tpl");
$tpl->parse("##LEFT##","left_tpl");
$tpl->parse("##RIGHT##","rigth_tpl");
$tpl->parse("##FOOTER##","footer_tpl");
$tpl->parse("##VIEW##","view_tpl");
$tpl->parse("MAIN","main_tpl");
$tpl->FastPrint();
exit();
//---------------
?>
-----------------


ปัญหาคือ พอผมย้าย ฟอร์ม มาอยู่ที่ formmember.html แล้วรัน มันก็ไม่ทำงาน ไงลองดูกันหน่อยน่ะครับ ว่าได้วิธีแก้ไขยังไงกันบ้าง



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-03-07 15:25:52 By : arsachi View : 661 Reply : 4
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Capture ภาพมาให้ดูหน่อยครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-08 09:31:55 By : mr.win
 


 

No. 2



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

เดาและวิเคราะห์เอาจากโค้ดนะครับ ไม่เคยใช้ library นี้
<?php 
include_once("./include/class.rFastTemplate.php");
$url1="../template/structure.html";
$url2="../template/formmember.html";
$url3="../template/top.html";
$url4="../template/left.html";
$url5="../template/rigth.html";
$url6="../template/footer.html";
$url7="../template/view.html";
//--------------
$tpl = new rFastTemplate("template");
// เดาว่านี่คือการกำหนดชื่อไฟล์ที่จะเอาไป include หรือแทนที่ด้วย parse()
$tpl->define(
    array(
        "main_tpl"   => $url1, // ../template/structure.html
        "detail_tpl" => $url2, // ../template/formmember.html
        "top_tpl"    => $url3, // ../template/top.html
        "left_tpl"   => $url4, // ../template/left.html
        "rigth_tpl"  => $url5, // ../template/rigth.html
        "footer_tpl" => $url6, // ../template/footer.html
        "view_tpl"   => $url7  // ../template/view.html
    )
);
//-------------


//--content

	
//--------------end content
// และมาถึงขั้นตอนการแทนที่
$tpl->parse("##TOP##","top_tpl"); // ../template/top.html
$tpl->parse("##CONTENT##","content_tpl"); // *** อันนี้มาจากไหน content_tpl ไม่เห็นมีใน define() ข้างบน
$tpl->parse("##LEFT##","left_tpl"); // ../template/left.html
$tpl->parse("##RIGHT##","rigth_tpl"); // ../template/rigth.html
$tpl->parse("##FOOTER##","footer_tpl"); // ../template/footer.html
$tpl->parse("##VIEW##","view_tpl"); // ../template/view.html
$tpl->parse("MAIN","main_tpl"); // ../template/structure.html
$tpl->FastPrint();
exit();
//---------------
?>
-----------------


สรุปว่าไม่มีการแทนที่ไฟล์ formmember.html ลงใน template ครับ
มันจึงไม่ทำงาน

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-08 09:56:01 By : cookiephp
 

 

No. 3



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ลอง view source ดูตอนรันก็ได้ครับ น่าจะเห็นว่า ไม่มีโค้ดของไฟล์ formmember.html รวมอยู่ด้วย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-08 09:57:30 By : cookiephp
 


 

No. 4



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

บางทีตอบไปเยอะๆ ก็อยากได้คำตอบกลับมาบ้างว่าคำตอบใช้ได้ไหม
แต่ไม่เป็นไร ต้องคิดไปในแง่ดีว่าเขาคงไม่ได้กลับมาอ่าน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-13 17:08:54 By : cookiephp
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : พรีวิวรูปภาพก่อนอัพโหลด ครับ ใช้ได้ครับ แต่...ติดตรงที่เอามาอยู่ในเทมเพลตคลาส
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่