<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="windows-874" %> http://www.siam2dev.com >> ชุมชนนักพัฒนาซอฟต์แวร์ของไทยแห่งใหม่
http://www.siam2dev.com >> ชุมชนนักพัฒนาซอฟต์แวร์แห่งใหม่
กลับหน้าแรก
 
ขอพระองค์จงทรงพระเจริญ
:: ติดต่อโฆษณา 089-6698280 ::
 
 
PHP ::ต้องการแสดงค่าใน input type file ( PHP )  Last Update :: 01/12/2550
 

โดย อ. นัฐพงศ์ ส่งเนียม


   ::
โจทย์
           คือต้องการเอาค่าจากฐานข้อมูลมาแสดงใน textfield ชนิด file ครับ
ไม่ทราบว่าต้องกำหนดให้แสดงค่าตรงไหน ช่วยแนะนำด้วยนะครับ
พอดีทำแบบนี้ครับ แล้วก็ไม่ได้ครับ
<input type="file" name="fbook_image" id="file" value="<?echo $vbookimage;?>"/>
ไม่ทราบเพราะอะไรครับ ซึ่งตัวแปร $vbookimage มีค่าครับ ถ้าสั่งแสดงข้างนอก textfield จะมีค่าครับ
และถ้าลองสั่งแสดงใน textfield ชนิด text ก็มีค่าแสดงครับ
<input type="text" name "textfield" value="<?echo $vbookimage;?>">
แต่พอเอาไปแสดงใน textfield ชนิด file มันไม่มีค่าแสดงเลยครับ ยังงัยฝากอาจารย์ช่วยบอกทีด้วยนะครับผมว่ามันเกิดจากอะไรครับผม ขอบคุณล่วงหน้านะครับผมที่กรุณาตอบครับผม...

 

   :: คำตอบ

           ปกติแล้ว มัน จะแสดง ค่าข้อความ ไม่ได้ ครับ แต่ มีวิธีที่สามารถช่วยได้ดังนี้ ครับ

ต.ย.
 
ตัวนี้ใช้ได้ คับ ผม ลอง Test ดู แล้ว

-------------------------------------------------
<html>

<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="formName" method="post" action="post.php">
<input type=file name=browseFile style="display: none;">
<input type=text name=file value="<?php echo 'test display text';?>">
<input type=button onClick="browseFile.click();file.value=browseFile.value;" value="SelectFile...">
</form>
</body>
</html>
-----------------------

ปล. สามารถเอปลี่ยน ตรง test display text เป็น ตัวแปรของ php ที่ต้องการได


 Last Update :: 01/12/2550
:: http://www.siam2dev.com ::
e-mail :: xnattapong@hotmail.com , songneam@gmail.com