# add upload section to website



## kelzr1987

Hi

I'm creating a website, i would like to add a section in my website where people can upload photos, videos, etc.

If anyone could help or have a website i could read up on that would be great

Thanks


----------



## carsey

You may use this one on the condition that all existing copyright stays in place and not removed. 
Change *"/mp3s/"* to where you want your files uploaded.

Also, make sure tha attached folder is in the same place as the script.



Code:


<?php
/*************************************************
 * Uploader
 *
 * This was coded by james addison and is aloud to be used by anyone who leaves the copyright there
 * 
 ****************************************************/

//Windows way
$uploadLocation = "./";
//Unix, Linux way
//$uploadLocation = "\tmp";

?>

<!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"> </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"> </div>
      <div id="result">
        <table width="100%">
<?php

$target_path = $_SERVER['DOCUMENT_ROOT'] . '[B]/mp3s/[/B]' . 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>

Make sure the styles folder remains in the same directory as upload.php (script above)


----------



## kelzr1987

Thank you so much


----------



## carsey

No problem.


----------



## DarkendGlory

is there a way of intergrating this into another page and is there a walkthrough on how to intall it completely becuase everytime i try i can never get the images to load thanks


----------



## carsey

There is a way you can integrate it into another webpage, but it would mean using a IFRAME to load the upload.php page and into the page you want it. 

I dont know whether this would work, but you could try using the PHP include tags in the HTML. Not sure what it will do/work.

*<?php include( "http://www.yoursite.com/upload.php" ); ?>*

To make the links load properly, you need to change the upload location from */MP3s/* (bold in the script) to a folder along the lines of *upload*
or something of your choice.


----------



## KoosHopeloos

@ DarkendGlory: if you use <?php include( "http://www.yoursite.com/upload.php" ); ?> it could be that your host requires you to save the page with a .shtml/.shtm extension. If both not work please check your webhost how to get Server Side Include (= <?php include( "http://www.yoursite.com/upload.php" ); ?>) to work.


----------



## j-a-m-z

I Wrote this script above and due to alot of intrest i have been developing it, it now has File Size Limits, File Type Limits, And Ip Logging, And Uploaded File List, And Many More Features, It will be out in a few days.

Hosting-town


----------



## Redcore

Another way to upload is to your MySQL database. I've tested this article before and it turned out well:

http://www.php-mysql-tutorial.com/php-mysql-upload.php

There are a few things I added...like allowing only certain mime types and checking the size of a file (and rejecting it if it does not meet requirements).


----------



## kurtlukas7

Im very nooby to website design.. could i have a little help? im starting a site... geekgamers.110mb.com lol.. as you can see i got the uploader on.. but.. how should the code look?



Code:


<?php
/*************************************************
 * Uploader
 *
 * This was coded by james addison and is aloud to be used by anyone who leaves the copyright there
 * 
 ****************************************************/

//Windows way
$uploadLocation = "./";
//Unix, Linux way
//$uploadLocation = "\tmp";

?>

<!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"> </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"> </div>
      <div id="result">
        <table width="100%">
<?php

$target_path = $_SERVER['DOCUMENT_ROOT'] . '/http://geekgamers.110mb.com/' . 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>

</body>

is that right?? please direct me in some direction... thanks!
I really just dont know what to replace the /mp3/ with 
and everytime (with the code above ) i try to upload to my site... it redirects me to a complete different one.. i know this is obviously do me not doing anything of this right... someone please tell me what to put in...


Thanks again


----------



## susan2009

I couldn't get this script to work either ... Is there supposed to be a </html> tag at the bottom of the page or not?? Any help is greatly appreciated!
Susan
P.S.What questions should I ask my host regarding the setup on their side??


----------



## aljey

carsey's post is more than helpful, it works great, thanks dude ray:


----------



## michaeljloomis

Thank you for this script. It worked very well. Did exactly what I needed it to.

Mike


----------



## djconners001

This works really well.

But was wondering if someone could help by telling me the extra code i need to add for what i am doing.

I want to add two extra box's underneath the File To Upload box.

The first box should say User ID and be in text field format and the second should say Upload details.

The script should create a folder under the document root (mp3s) in this example with whatever name as added for User ID (unless already existing) and the files should be placed in this folder along with a txt document containing the Upload Details Txt.

I have put the boxes in already which is the easy part but just need some help with the code.

It would be greatly appreciated.


----------



## Slapshot

If I were you, I wouldn't use that. It's unsecure.


----------



## djconners001

The actual files being uploaded are not of any great important and contain no confidential data.

Do you know of another method i could use? i looked at the mysql table page and the whole thing looked a bit complicated.

Regards,
J


----------



## Slapshot

Not just the files, your whole site could be hacked.

Also for those of you whole are still having problems, try to CHMOD the upload folder to 777


----------



## tomtomgo

So I am using this script and it works awesome... however... is there anyway anyone would be able to tell me how to add an email for to it... like i want an email saying that someone uploaded a file and there name... 

IE

Name: tom
phone number: 2323232323
Special instructions:



file uploaded:

That way if i have multiple people upload i know which file belongs to whom


----------



## courtneynlo

thanks so much! used iframe and worked perfectly  

question though -- is there a limit on the file size this will allow? can you set a limit?


----------



## wicked white

*Help a noob*

Sorry to bump an old thread. :4-dontkno

I ran across this via a google search. I am looking to add an upload manager to my site obviously. 

I configured the "/mp3s/" directory to "/mydirectory/" as above.

I embedded the code properly (I think) and can see the images and what not in the style directory I downloaded.

PROBLEM IS-
Once I click upload, It shoots my browser over to this URL - 

mydomain.com/<?php%20echo%20$_SERVER['PHP_SELF'];%20?>

Help a noob? :sigh:


----------



## Click SSL

This script is really very helpful. I was looking for this types of script from so long time.Thank you for sharing this.


----------



## wicked white

NVM 

Figured her out.


----------



## nebastion

*Re: Help a noob*



wicked white said:


> Sorry to bump an old thread. :4-dontkno
> 
> I ran across this via a google search. I am looking to add an upload manager to my site obviously.
> 
> I configured the "/mp3s/" directory to "/mydirectory/" as above.
> 
> I embedded the code properly (I think) and can see the images and what not in the style directory I downloaded.
> 
> PROBLEM IS-
> Once I click upload, It shoots my browser over to this URL -
> 
> mydomain.com/<?php%20echo%20$_SERVER['PHP_SELF'];%20?>
> 
> Help a noob? :sigh:



Sup, 

How did you figure it out??? What did you do? Same is happening to me....

Regards 
Neb


----------



## camstans

Great simple code that works. Thanks


----------



## DWnew

Is the new script posted somewhere? I am new to this forum.

thanks


----------



## Laxer

I am not aware of an updated script.

*If you need help with this script please create a new thread stating the problems you are having.*

And the design team will help get you up and running!


----------

