Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Upload Script

  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Upload Script

    I need a script to enable user to upload files onto my webspace.

    Please Help.

    ~ fEaR

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    i'm using this script,, seems to work pretty well..

    upload.php script:
    PHP Code:

    <html>
    <head><title>Upload Details</title></head>
    <style type="text/css">
    <!--
    .style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
    -->
    </style>

    <?

    //MySQL DB Info:

    $DBhost "localhost";
    $DBuser "root";
    $DBpass "sql";
    $DBName "pictures";


    $save_path="C:\\Program Files\\Apache Group\\Apache2\\htdocs\\pics\\images\\";


    $file $_FILES['userfile'];
    $k count($file['name']);


    for(
    $i=$i $k $i++)
    {


        
    $FileName $file['name'][$i];
        
    $FileSize $file['size'][$i];

        if(isset(
    $save_path) && $save_path!="")
        {
            
    $name split('/',$file['name'][$i]);

            
    move_uploaded_file($file['tmp_name'][$i], $save_path $name[count($name)-1]);
        }

    }

    if(! isset(
    $save_path) || $save_path =="")
    {
        echo 
    'Files have not been saved, please edit upload.php to match your configuration';
    }


    ?>
    </table>



    <form action="func.php?func=addpic" method=post>
    <table width="698" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th width="160" scope="row"><span class="style3">Gallery </span></th>
        <td width="538">


    <select name="PicSection">
    <?
    $link 
    mysql_connect($DBhost$DBuser$DBpass) or die('Login details incorrect');
    $db_selected mysql_select_db($DBName$link) or die('Database name incorrect');

    $result mysql_query('SELECT * FROM picsections');

    while (
    $rows mysql_fetch_array($result))
    {

    $Sid=$rows[0];
    $SecName $rows[1];
    echo 
    "<option value=$Sid>$SecName</option>";
    }
    mysql_close($link);




    ?>
      </select>



        </td>
      </tr>
      <tr>
        <th width="160" scope="row"><span class="style3">File name </span></th>
        <td width="538"><input type=text name="PicName" value="<? echo $FileName?>" readonly></td>
      </tr>
      <tr>
        <th width="160" scope="row"><span class="style3">File Size </span></th>
        <td width="538"><input type=text value="<? echo $FileSize?>" readonly></td>
      </tr>  <tr>
        <th scope="row"><span class="style3">Picture Title </span></th>
        <td><input type=text name="PicTitle"></td>
      </tr>
      <tr>
        <th scope="row"><span class="style3">Description</span></th>
        <td><textarea cols="50" rows="6" name="PicDesc"></textarea></td>
      </tr>
      <tr>
        <th scope="row">&nbsp;</th>
        <td><input type=submit></td>
      </tr>
    </table>
    </form>


    </body>
    </html>

    uploadform.php
    PHP Code:

    <html>
    <head><title>File Upload Tester</title></head>
    <body>

    <form  enctype="multipart/form-data" action="upload.php" method="post">

    <table border="0" cellpadding="10" align="center" width="770" align="center">
    <tr><td align="center"><font size=3 face=verdana>File Upload Test</font></td></tr>

    <tr>
      <td  valign="top" align="center">
        <table border=0 align="center" cellpadding=3>
        <tr><td><input type="file" name="userfile[0]"></td></tr>
        <tr><td colspan=2 align="center">
            <input type="hidden" name="sessionid" value="<?= $sid ?>">
            <input type="submit" value='Upload!'>
        </td></tr></table>
    </td>
    </tr>
    <tr><td>
    </table>


    </form>

    </body>
    </html>
    hope that helps.

    -Ken

  • #3
    New Coder
    Join Date
    Jul 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    and one more thing.

    i have cpanel installed on my webspace.

    how can i create a SQL database with the name and pass that i want.

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you want to do it through the cpanel, you probably have phpMyadmin on there somewhere. That will allow you to access and manipulate your databases manually.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •