Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 





Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Web Design & Programming Discussion of web design, and server-side & client-side scripting

Closed Thread
 
Thread Tools
Old 08-05-2007, 03:32 PM   #1 (permalink)
Moderator, TSF Articles
 
carsey's Avatar
 
Join Date: Aug 2006
Location: Hunwick, Co. Durham England
Posts: 9,380
OS: XP Pro SP3

My System

Send a message via MSN to carsey
File Uploader script for Your website

Hi people

This PHP script is aimed to make your website have a great feature of a uploader so people can easily upload files/images to your hosting servers without and hassle.

First of all, we need to have a look at the code.

Code:
<?php
/*************************************************
 * Created By Hosting-Town.com
 * Open to use for anyone
 * CopyRight must remain in place
 * Hosting-town.com
 ****************************************************/

//Upload Locacation E.G. ./uploads/
$uploadLocation = "./";


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title>Uploader!</title>
   <link href="style/style.css" rel="stylesheet" type="text/css" />
   <style type="text/css">
<!--
.style1 {
	font-size: 10px;
	font-weight: bold;
}
-->
   </style>
</head>
<body>
    <div id="main">
      <div id="caption">UPLOAD FILE</div>
      <div id="icon">&nbsp;</div>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="fileForm" id="fileForm" enctype="multipart/form-data">
        File to upload:<center>
        <table>
          <tr><td><input name="upfile" type="file" size="36"></td></tr>
          <tr><td align="center"><p><br/>
            <input class="text" type="submit" name="submitBtn" value="Upload">
          </p>
              <p align="right" class="style1"><a href="http://hosting-town.com">Made By Hosting-Town.com - James Addison </a></p></td>
          </tr>
        </table></center>  
      </form>
<?php    
    if (isset($_POST['submitBtn'])){

?>
      <div id="caption">RESULT</div>
      <div id="icon2">&nbsp;</div>
      <div id="result">
        <table width="100%">
<?php

$target_path = $_SERVER['DOCUMENT_ROOT'] . '/mp3s/' . basename( $_FILES['upfile']['name']);
if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path)) {
    echo "The file".  basename( $_FILES['upfile']['name']).
    "has been sucessfully uploaded.";
} else{
    echo "There was an error uploading the file, please try again!";
}

?>
        </table>
     </div>
<?php            
    }
?>
    <div>
	
	Please note: You are solely responsible for any content that you may choose to upload to this site.  The site owner/administrator will not accept ANY responsibility regarding illegal content that you upload.  Should you not agree to these terms, please leave this page now.
</body>
This is the code that will allow people to upload to your site.

*Please note that there is currently no file restrictions on this script so anyone visiting your site will be able to upload any type of file of any size*

Now, open the above in your favourite text editor, such as notepad and change the area in bold in the code to the location as to where you want the files to be uploaded to. For example: If you want all uploads go to a folder called /uploads you would make the code look like:

Code:
$target_path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/' . basename( $_FILES['upfile']['name']);
Now, after you have made the above changes, save the files as uploads.php and upload it to the area of your site. Also, upload the folder styles to the same directory as upload.php

Also, remember to make sure that your uploads folder has full write permissions (CHMOD 777).

Now, you will be able to test the script by going to the URL where you uploaded the PHP file.

If successful, the script will tell you its successful by showing: The file (your filename) has been successfully uploaded.


This script can be used openly by anyone as long as the full copyright markings stay in place. Please bear in mind, this script was written in our own time for free for you.
__________________

carsey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Old 08-05-2007, 03:36 PM   #2 (permalink)
Moderator, TSF Articles
 
carsey's Avatar
 
Join Date: Aug 2006
Location: Hunwick, Co. Durham England
Posts: 9,380
OS: XP Pro SP3

My System

Send a message via MSN to carsey
Re: File Uploader script for Your website

STAFF... This is a incomplete version of this article/script. New version is to include a easy setup configuration.

PLEASE LEAVE THIS ONE IN THE MODERATED QUEUE
__________________

carsey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Closed Thread


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -7. The time now is 06:20 PM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81