001.
<script language=
"javascript"
type=
"text/javascript"
>
002.
<!--
003.
004.
function
startUpload(){
005.
document.getElementById(
'f1_upload_process'
).style.visibility =
'visible'
;
006.
document.getElementById(
'f1_upload_form'
).style.visibility =
'hidden'
;
007.
return
true;
008.
}
009.
010.
function
stopUpload(success){
011.
var
result =
''
;
012.
if
(success == 1){
013.
result =
'<span class="msg">การอัพโหลดไฟล์สมบูรณ์'
+success+
'<\/span><br/><br/>'
;
014.
}
else
if
(success == 2){
015.
result =
'<span class="emsg">ไฟล์ที่เลือกไม่สามารถอัพโหลดได้ อนุญาติให้ใช้ไฟล์ที่มีนามสกุล jpg,jpeg,png,bmp,ico,gif เท่านั้น<\/span><br/><br/>'
;
016.
}
else
{
017.
result =
'<span class="emsg">ผิดพลาดไม่สามารถอัพโหลดไฟล์ได้ '
+success+
'<\/span><br/><br/>'
;
018.
}
019.
document.getElementById(
'f1_upload_process'
).style.visibility =
'hidden'
;
020.
021.
022.
document.getElementById(
'f1_upload_form'
).innerHTML = result +
'<fieldset><dl><dt><label for="upload">เลือกไฟล์ :</label></dt><dd><input type="file" name="upload_file" id="upload_file" /></dd></dl><dl><dt><label for="txt_description">คำอธิบายรูป :</label></dt><dd><textarea name="txt_description" id="txt_description" rows="5" cols="45"></textarea></dd></dl><dl class="submit"><input type="submit" name="submit" id="submit" value="อัพโหลด" /></dl><iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe></fieldset>'
;
023.
024.
document.getElementById(
'f1_upload_form'
).style.visibility =
'visible'
;
025.
document.getElementById(
'show_file'
).src = document.getElementById(
'show_file'
).src;
026.
027.
return
true;
028.
029.
}
030.
031.
</script>
032.
<?php
033.
034.
035.
$lastname
=
end
(
explode
(
'.'
,
$_FILES
[
'upload_file'
][
'name'
] ) ) ;
036.
$file_name
= myfnc::GenPathFile(3).
'room-info-'
.
$news_id
.
'-'
.
date
(
'Y-m-d-H-i-s'
).
'.'
.
$lastname
;
037.
038.
$result
= 0;
039.
040.
if
(@move_uploaded_file(
$_FILES
[
'upload_file'
][
'tmp_name'
],
$file_name
)) {
041.
$data_max
=
$odbc
->query(
"SELECT MAX(room_file_no) AS num FROM room_information_file WHERE room_no = '{$room_no}'"
);
042.
$id_max
= myfnc::autoID(
$data_max
[0][
'NUM'
],0);
043.
$odbc
->query("
044.
INSERT INTO room_information_file (
045.
room_no ,
046.
room_file_no ,
047.
mdt_id ,
048.
file_name ,
049.
file_description ,
050.
file_status
051.
) VALUES (
052.
'{$room_no}'
,
053.
{
$id_max
} ,
054.
1 ,
055.
'{$file_name}'
,
056.
'".$_REQUEST['
txt_description
']."'
,
057.
'Y'
058.
)
059.
");
060.
$result
= 1;
061.
}
else
{
062.
$result
=
$_FILES
[
'upload_file'
][
'error'
];
063.
}
064.
065.
066.
067.
068.
069.
070.
071.
sleep(1);
072.
?>
073.
074.
<script language=
"javascript"
type=
"text/javascript"
>window.top.window.stopUpload(<?php
echo
$result
; ?>);</script>
075.
076.
</head>
077.
078.
<body >
079.
080.
<div
class
=
"form"
id=
"f1_upload_process"
style=
"visibility:hidden;"
>
081.
<dl>
082.
<dt>Loading...</dt>
083.
<dd><img src=
"images/icons/loader.gif"
/></dd>
084.
</dl>
085.
</div>
086.
087.
<div
class
=
"form"
id=
"f1_upload_form"
>
088.
<form action=
""
method=
"post"
enctype=
"multipart/form-data"
target=
"upload_target"
class
=
"niceform"
onsubmit=
"startUpload();"
>
089.
<!--<form action=
""
id=
"f1_upload_form"
method=
"post"
enctype=
"multipart/form-data"
class
=
"niceform"
>-->
090.
<fieldset>
091.
<dl>
092.
<dt><label
for
=
"upload"
>เลือกไฟล์ :</label></dt>
093.
<dd><input type=
"file"
name=
"upload_file"
id=
"upload_file"
/></dd>
094.
</dl>
095.
<dl>
096.
<dt><label
for
=
"txt_description"
>คำอธิบายรูป :</label></dt>
097.
<dd><textarea name=
"txt_description"
id=
"txt_description"
rows=
"5"
cols=
"45"
></textarea></dd>
098.
</dl>
099.
<dl
class
=
"submit"
>
100.
<input type=
"submit"
name=
"submit"
id=
"submit"
value=
"อัพโหลด"
/>
101.
</dl>
102.
<iframe id=
"upload_target"
name=
"upload_target"
src=
"#"
style=
"width:0;height:0;border:0px solid #fff;"
></iframe>
103.
</fieldset>
104.
</form>
105.
</div>
106.
<iframe id=
"show_file"
name=
"show_file"
src=
"modules/main/room_information_file.php"
style=
"width:100%;height:auto; min-height:500px;border:1px solid #FFFFFF;"
></iframe>
107.
108.
109.
</body>