• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

File upload feature implemented

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
28 posts • Page 2 of 2 • 1, 2

Postby todhend » Tue Jun 01, 2010 2:13 am

adjust your php.ini to allow for large uploads and adjust your memory accordingly

the folder upload form goes into the chat template around line 122 of chat.html.tpl.php

in the data folder I placed a folder uploads which holds the uploads

//start upload form
Code: Select all
<div id="upload">
    <form enctype="multipart/form-data" action="./uploader.php" method="POST">
   <input name="uploadedfile"  type="file" /><br>
<div id="uploadbutton">
    <input type="submit" value="Upload File" />
</div>
    </form>
</div>


//end upload form

this calls up uploader.php which does the work,

//uploader.php
Code: Select all
<?php
header('Expires: Thu, 21 Jul 1977 07:30:00 GMT');   // When yours truly first set eyes on this world! :)
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');      // For HTTP/1.0 compability
require_once "src/phpfreechat.class.php";
ini_set("display_errors", 0);

// Where the file is going to be placed
$target_path = "./data/uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path));

?>

<html>
<head>
<script type="text/javascript">

         <!--
         function delayer(){
            document.location = './nchat.php'; // change this to your chat index
         }
         //-->
<!--
function silentErrorHandler() {return true;}
window.onerror=silentErrorHandler;
//-->      
      </script>
      
</head>

<body onload=" setTimeout('delayer()', 500);">

</body>
</html>


end uploader.php//


style.css.php controls where this is on the page , around lines 466 and below, note some are not hooked in

Code: Select all
div#upload {
  margin: 0; padding: 0;
  position: absolute;
  right: 270;
  top: 0;
  background-color: #fff;
  border: #cccccc solid 1px;
  color: 000;
  font-family: verdana;
}

div#uploaded {
margin: 0; padding: 0px;

}


div#uploadbutton {
  margin: 0; padding: 0;
  position: absolute;
  right: 40;
  top: 25;

}

div#uploadresults {

  margin: 0; padding: 0;
  position: absolute;
  z-index: 100;
  right: 0;
  top: 0;
  font-size: 14px;
  height: 1.9em;
  cursor: pointer;

}


this is an iframe that pulls in an ajax seamless refresh script "refresh.php" that pulls in the file viewer "viewfiles.php"

Code: Select all
<div id="uploadresults">

<iframe src="./refresh.php" class="i_frame"  id="i_frame" style="width: 265px; height: 95px;" scrolling="auto" frameborder="0" style="overflow-y:scroll;"></iframe>

</div>


//start refresh.php

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
   <head>
       <script type="text/javascript">
      <!--
       
         var vUri = 'viewfiles.php'
         
         var vRequest;
         
         function getRequest()
         {
            vRequest = null;
             
            if (window.XMLHttpRequest)
            {
               vRequest = new XMLHttpRequest();
            }
            else if (window.ActiveXObject)
            {
               try
               {
                  vRequest = new ActiveXObject('Msxml2.XMLHTTP');
               }
               catch (err)
               {   
                  try
                  {
                     vRequest = new ActiveXObject('Microsoft.XMLHTTP');
                  }
                  catch (err)
                  {
                     return (false);
                  }
               }
            }
             
            vRenew = new Date();
             
            vTest = /?/;
             
            vNewUri = vUri + (vTest.test(vUri)?'&':'?') + 'renew=' + vRenew.getTime();
             
            vRequest.onreadystatechange = catchChange;   
            vRequest.open('GET', vNewUri, true);   
            vRequest.send(null);
         }
         
         function catchChange()
         {
            if (vRequest.readyState == 4 && vRequest.status == 200)
            {
               document.getElementById('i_reload').innerHTML = vRequest.responseText;
               
               setTimeout('getRequest()', 5000);
            }
         }
         
         getRequest();
         
      //-->
      </script>   
 
   </head>

   <body>
      <div class="i_frame" id="i_reload"></div>
   </body>
</html>


//end refresh.php



//start viewfiles.php

Code: Select all
require_once "src/phpfreechat.class.php";

$target_path = "./data/uploads/";

filesInDir($target_path);

function filesInDir($tdir)
{
        $dirs = scandir($tdir);
        foreach($dirs as $file)
        {
                if (($file == '.')||($file == '..'))
                {
                }
                elseif (is_dir($tdir.'/'.$file))
                {
                        filesInDir($tdir.'/'.$file);
                }
                else
                {
                echo "<img src="images/download.gif" ><a style="text-align:right;color: steelblue;text-decoration: none;font-style: italic;font-weight:bold;font-size:14px" href="$tdir/$file" target="_blank"> $file </a><br />";
                                   
                }       
        }
}
?>


//end viewfiles.php



note: the images will be missing, sorry
Last edited by todhend on Tue Jun 01, 2010 1:18 pm, edited 1 time in total.
http://nflpick.net free football picks
http://tdah.us free webmail script
todhend
Member
 
Posts: 83
Joined: Tue Jan 19, 2010 9:03 pm
Location: Missouri
  • Website
Top

Postby DreadPirateVane » Tue Jun 01, 2010 2:37 am

awesome,, thanx very much,, is there anyway to make this only available to admins?
Station Built by the Bands,, For the Fans!!
DreadPirateVane
Member
 
Posts: 47
Joined: Tue Dec 23, 2008 10:44 pm
Location: Kansas City, Mo.
  • Website
  • YIM
Top

Postby todhend » Tue Jun 01, 2010 3:37 am

you would need to write a script for that its just an open simple upload
http://nflpick.net free football picks
http://tdah.us free webmail script
todhend
Member
 
Posts: 83
Joined: Tue Jan 19, 2010 9:03 pm
Location: Missouri
  • Website
Top

Postby DreadPirateVane » Tue Jun 29, 2010 3:36 am

after much time messing with this script,, i just cannot seem to be able to get it to work correctly,, not sure of exactly where the new pages should be and if i have labeled the directories correctly,,

Code: Select all
Warning: scandir(http://infernalrockradio.com/CMS/components/com_jpfchat/pfc/data/uploads/) [function.scandir]: failed to open dir: not implemented in /home/wykkydb/public_html/CMS/components/com_jpfchat/pfc/themes/default/viewfiles.php on line 10

Warning: scandir() [function.scandir]: (errno 115): Operation now in progress in /home/wykkydb/public_html/CMS/components/com_jpfchat/pfc/themes/default/viewfiles.php on line 10

Warning: Invalid argument supplied for foreach() in /home/wykkydb/public_html/CMS/components/com_jpfchat/pfc/themes/default/viewfiles.php on line 11
Station Built by the Bands,, For the Fans!!
DreadPirateVane
Member
 
Posts: 47
Joined: Tue Dec 23, 2008 10:44 pm
Location: Kansas City, Mo.
  • Website
  • YIM
Top

Postby todhend » Tue Jun 29, 2010 8:43 pm

here's an example, you would need to customize it a bit for your needs but I would have to discuss how you set this up further in the chat room bellow to help out further

http://spfldmo.com/sites/chat/
http://nflpick.net free football picks
http://tdah.us free webmail script
todhend
Member
 
Posts: 83
Joined: Tue Jan 19, 2010 9:03 pm
Location: Missouri
  • Website
Top

Postby Bebbaboy » Mon Aug 16, 2010 7:33 pm

HI, whare does the ifram code go, in what file and whare?
Bebbaboy
New member
 
Posts: 2
Joined: Mon Aug 16, 2010 7:00 pm
Top

Postby todhend » Tue Aug 17, 2010 5:05 pm

chat.html.tpl.php

I've devised a new one that uses 2 iframes and refreshes without refreshing the chat screen, Ill post it soon
http://nflpick.net free football picks
http://tdah.us free webmail script
todhend
Member
 
Posts: 83
Joined: Tue Jan 19, 2010 9:03 pm
Location: Missouri
  • Website
Top

Postby waiheke » Sun Oct 31, 2010 3:34 pm

todhend wrote:chat.html.tpl.php

I've devised a new one that uses 2 iframes and refreshes without refreshing the chat screen, Ill post it soon

come bacccckkkkkkkk ......
waiheke
Member
 
Posts: 126
Joined: Sun Sep 12, 2010 4:33 pm
Top

Postby todhend » Mon Nov 01, 2010 2:43 am

sorry been away, here's the link to the demo

http://spfldmo.com/sites/no_refresh/index.php

you can download it here

http://spfldmo.com/sites/stand_alone_no ... efresh.zip

still no security or safeguards just bare upload
http://nflpick.net free football picks
http://tdah.us free webmail script
todhend
Member
 
Posts: 83
Joined: Tue Jan 19, 2010 9:03 pm
Location: Missouri
  • Website
Top

Postby waiheke » Tue Nov 09, 2010 1:35 pm

Man that rocks, at your website - smoothly set out - congratulations :)
waiheke
Member
 
Posts: 126
Joined: Sun Sep 12, 2010 4:33 pm
Top

Postby chattunnel » Mon May 28, 2012 4:07 am

Santiagos links are broken. I gave todhends script a try. Created viewfiles.php, refresh.php, iframe.php, uploader.php, edited style.css.php and chat.html.tpl.php with no avail. My chat is http://www.chattunnel.com/chat/ctchat.php this is the iframe.php http://www.chattunnel.com/chat/iframe.php
Okay I got it working but the form is free floating at the top of the page and not in the chat?
Last edited by chattunnel on Mon May 28, 2012 4:38 am, edited 1 time in total.
http://www.chattunnel.com/chat/ctchat.php
chattunnel
Member
 
Posts: 10
Joined: Fri May 11, 2012 3:16 pm
Location: http://www.chattunnel.com
  • Website
Top

Postby provotector » Wed May 30, 2012 5:57 am

todhend wrote:sorry been away, here's the link to the demo

http://spfldmo.com/sites/no_refresh/index.php

you can download it here

http://spfldmo.com/sites/stand_alone_no ... efresh.zip

still no security or safeguards just bare upload

Links broken...
http://www.shurchat.com
provotector
Member
 
Posts: 33
Joined: Fri Apr 27, 2012 4:09 am
Top

Postby todhend » Wed May 30, 2012 4:35 pm

those links are broken because that was posted 2 years ago and Im on a different server now, Ill try to dig around for the files or create them again in the next week, Ill get back to ya :)
http://nflpick.net free football picks
http://tdah.us free webmail script
todhend
Member
 
Posts: 83
Joined: Tue Jan 19, 2010 9:03 pm
Location: Missouri
  • Website
Top

Previous

Post a reply
28 posts • Page 2 of 2 • 1, 2

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 2 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub