Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-11-2010, 06:25 AM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help Creating A File Upload Page Please

Hi guys & girls, I'm looking to create a simple file upload page so I can offer my moderators the ability to upload 1 specific file to a specific folder. I'd like the page to take my forum theme which I can do already by creating a custom page and template. The option of usergroup access checking would be nice but not essential as the page will not be public.

It's just a simple upload script I'm looking for, which I can customize to suite my file and folder requirements and then build it into a custom template perhaps.

Any help would be greatly appreciated.
Many thanks
B16MCC.
Reply With Quote
  #2  
Old 11-11-2010, 11:34 AM
Outbackmark's Avatar
Outbackmark Outbackmark is offline
 
Join Date: Jun 2007
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could try this mod https://vborg.vbsupport.ru/showthrea...ht=file+upload
Reply With Quote
  #3  
Old 11-11-2010, 02:19 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is the programming *discussion* forum which means you get help with programming the page yourself. This usually starts by you posting your code and saying what the problem is. If you are asking for someone else to do the whole thing for you, then you need to post in either the Unpaid or Paid requests forum.
Reply With Quote
  #4  
Old 11-12-2010, 06:41 AM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Outbackmark, thanks for the link , I am actually already that mod but it's far too advanced for this simple task I want to offer my moderators.

OK Lynne, here's what I've got so far.

Here's the custom template I've made that's linked to a navbar tab.
HTML Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    <title>{vb:raw vboptions.bbtitle}</title>
    {vb:raw headinclude}
  </head>
  <body>
    
    {vb:raw header}
    
    {vb:raw navbar}
   
    <h2 class="blockhead">Services Database Upload</h2>
    <div class="blockbody">
      <div class="blockrow">

<center>
<br></br>
Welcome Moderators, to the Services Database update page.
<br></br>
Download The Database <a href="http://www.xxxxxxxxxx.com/spreadsheet.xlsm">Here.</a> 
<br></br>
<br></br>
When you have finished updating the spreadsheet please upload it using the form below.
<br></br>
<br></br>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">spreadsheet.xlsm : </label>
<input type="file" name="file" id="file" />
<br />
<br></br>
<input type="submit" name="submit" value="Submit" />
</form>
</center>
      </div>
    </div>
    {vb:raw footer}
  </body>
</html>

That's my simple upload form and here's the associated php script that it runs.

PHP Code:
<?php
if ($_FILES["file"]["size"] < 4194304)
  {
  if (
$_FILES["file"]["error"] > 0)
    {
    echo 
"Return Code: " $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo 
"Upload: " $_FILES["file"]["name"] . "<br />";
    echo 
"Type: " $_FILES["file"]["type"] . "<br />";
    echo 
"Size: " . ($_FILES["file"]["size"] / 4096) . " Kb<br />";
    echo 
"Temp file: " $_FILES["file"]["tmp_name"] . "<br />";

    if (
file_exists("upload/" $_FILES["file"]["name"]))
      {
      echo 
$_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      
move_uploaded_file($_FILES["file"]["tmp_name"],
      
"uploads/" $_FILES["file"]["name"]);
      echo 
"Stored in: " "uploads/" $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo 
"Invalid file";
  }
?>
OK , yes its very basic but it works, I'm not a web coder. I'm happy , for now, with the template HTML code but I need a little help with the PHP if possible please.

Firstly, when it checks to see if the file exists, I simply want to over rite it, if it does exist.

Secondly, when the uploaded file is moved to the Uploads folder, I want to change this to a location outside of my forum root folder if possible.

A bonus would be a check to see if the file is the correct name which is 'services_db.xlsm'

A second bonus would be to check if the user is a member of the allowed user groups and deny access to the page if they are not. Although the navbar tab is hidden from certain user groups the page could still be addressed directly and so a user group check would make it more secure.

I'm sure what seem to me like huge hurdles in this simple page are very easily over come with a little expert help. Any help would be greatly appreciated and if a donation to a coder for example, would help then of course I'd be happy to do so.
Many thanks.
B16MCC
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:33 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04936 seconds
  • Memory Usage 2,210KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete