2525
2626function pass_contents ($ content )
2727{
28+ if (trim ($ content ) == '' ) {
29+ show_form (); print ("<span id='msg' style='font-size:9px;color: red;'>Error occured. Please try to upload again</span> " );
30+ return ;
31+ }
2832 $ type = $ _GET ['type ' ];
2933 print <<<JS
30- <script type="text/javascript">parent.App.Pages.WEB_DOMAIN.setSSL(' {$ contents }', ' {$ type }');</script>
34+ <textarea id="result" style="display: none;"> {$ content }</textarea>
35+ <script type="text/javascript">parent.App.Pages.WEB_DOMAIN.setSSL(' {$ type }', this);</script>
3136JS ;
3237}
3338
3439function handleUpload ()
3540{
3641 if ($ _FILES ["upload-ssl " ]["size " ] < 20000 ) {
3742 if ($ _FILES ["upload-ssl " ]["error " ] > 0 ) {
38- return show_form () . "Error occured. Please try to upload again " ;
43+ show_form (); print ("<span id='msg' style='font-size:9px;color: red;'>Error occured. Please try to upload again</span> " );
44+ return ;
3945 }
4046 else {
41- /*echo "Upload: " . $_FILES["file"]["name"] . "<br />";
42- echo "Type: " . $_FILES["file"]["type"] . "<br />";
43- echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
44- echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";*/
45-
4647 $ contents = file_get_contents ($ _FILES ["upload-ssl " ]['tmp_name ' ]);
4748 return show_form ().pass_contents ($ contents );
48-
49- /*if (file_exists("upload/" . $_FILES["file"]["name"])) {
50- echo $_FILES["file"]["name"] . " already exists. ";
51- }
52- else {
53- move_uploaded_file($_FILES["file"]["tmp_name"],
54- "upload/" . $_FILES["file"]["name"]);
55- echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
56- }*/
5749 }
5850 }
5951 else {
60- return show_form () . "Filesize is too large. Please ensure you are uploading correct file " ;
52+ show_form (); print ("<span id='msg' style='font-size:9px;color: red;'>Filesize is too large. Please ensure you are uploading correct file</span> " );
53+ return ;
6154 }
6255}
6356
@@ -71,7 +64,29 @@ function show_form()
7164 }
7265
7366 print <<<HTML
74- <form action="" method="post" enctype="multipart/form-data"><input type="hidden" value="true" name="process"><input type="file" name="upload-ssl" onChange="document.forms[0].submit()"/></form>
67+ <script type="text/javascript">
68+ function upload()
69+ {
70+ var l_dot = '';
71+ document.getElementById('form-upl').style.display = 'none';
72+ try {
73+ document.getElementById('msg').style.display = 'none';
74+ } catch(e){};
75+ document.getElementById('form-loading').style.display = 'block';
76+ setInterval(function(){
77+ if (l_dot == '...') {
78+ l_dot = '';
79+ }
80+ l_dot += '.';
81+ document.getElementById('form-loading').innerHTML = 'Processing'+l_dot;
82+ }, 500);
83+ setTimeout(function() {
84+ document.forms[0].submit();
85+ }, 1000);
86+ }
87+ </script>
88+ <p id="form-loading" style="font-size:11px;color:#333;"></p>
89+ <form id="form-upl" action="" method="post" style="padding:0;margin:0" enctype="multipart/form-data"><input type="hidden" value="true" name="process"><input type="file" name="upload-ssl" onChange="upload();"/></form>
7590HTML ;
7691}
7792
0 commit comments