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 12 of 12
  1. #1
    Regular Coder BabyJack's Avatar
    Join Date
    Apr 2008
    Location
    Somewhere.
    Posts
    602
    Thanks
    43
    Thanked 6 Times in 6 Posts

    How would I create a form that uploads things to a webpage?

    Hi, I was wanting an upload form similar to thesimsresource.com. Where you upload a .sims2pack file, an image and a description and then, once uploaded, goes into a page. Without me or an other administrator putting them on.

    How would I do this - and I am not willing to pay any money for this.


    BabyJack
    Enlightenment in Coding
    Validate before Posting | Google is your friend for PC Problems | Make sure you have a doctype

  • #2
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    http://www.tizag.com/phpT/fileupload.php shows you how to make an upload form in php/html. You'll need to make a few other forms for any other info that you want to be displayed with the webpage. The submit action for the form should send the $_POST info to a script that will store the information in either a flat file or a database. I'd recommend using a database.

    Here's a script I wrote for one of my clients once:
    PHP Code:
    <div id="center">
    <?
    include_once("inc.php");
    if(
    $session != 1) {
            print 
    $login_error;
            return;
    }
    db_connect();
    if(isset(
    $_GET['submit'])) {
            
    $target_path "photos/";
            
    $target_path $target_path basename($_FILES['uploadedfile']['name']);
            if(
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
                    
    $time time();
                    
    $path "photos/";
                    
    $filename $time.".jpg";
                    
    $medium_thumb $time."_med.jpg";
                    
    $small_thumb $time."_small.jpg";
                    if(
    rename($target_path,$path.$filename)) {
                            
    exec("convert ".$path.$filename ." -resize 90x68 ".$path.$small_thumb);
                            
    exec("convert ".$path.$filename ." -resize 160x120 ".$path.$medium_thumb);
                    } else {
                            print 
    "Some sort of error occured! Feeling helpful? Contact your webadmin.</div><div id=\"footerline\"></div>";
                    }
                    
    $description = (empty($_POST['desc'])) ? "" mysql_real_escape_string($_POST['desc']);
                    
    $query "INSERT INTO `photos` (`desc`,`filename`,`med_thumb`,`small_thumb`)
                            VALUES ('$description','$filename','$medium_thumb','$small_thumb')"
    ;
                    
    mysql_query($query);
                    echo 
    "The file ".  basename$_FILES['uploadedfile']['name']). " has been uploaded";
            } else{
                    echo 
    "There was an error uploading the file, please try again!";
            }
            
    db_disconnect();
            return;
    } else{
    ?>
    <form enctype="multipart/form-data" action="index.php?page=upload_photos&submit=true" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
    Photo to upload: <input name="uploadedfile" type="file" /><br /><br/>
    Photo description <i>(This will appear under the photo in the gallery)</i>:<br/> <input type="text" name="desc" size="50"><br/><br/>
    <div align="center"><input type="submit" value="Upload!" /></div>
    </form>
    <?
    }
    ?>
    As you can see, my action= for the form submits to the same document that holds the form - this is a self containing document! The only things you need to change are the action= so that it does not require index.php, the database table names, and you'd have to implement dbconnect() and db_disconnect().

  • #3
    Regular Coder BabyJack's Avatar
    Join Date
    Apr 2008
    Location
    Somewhere.
    Posts
    602
    Thanks
    43
    Thanked 6 Times in 6 Posts
    I am new to PHP, but what do I put to show the uploads in another webpage?
    And how do I upload another file type (.sims2Pack)?
    Last edited by BabyJack; 05-20-2008 at 04:44 PM.
    Enlightenment in Coding
    Validate before Posting | Google is your friend for PC Problems | Make sure you have a doctype

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    There are other issues here that will change how it can (or should) be done.

    1) How many file uploads do you expect?
    2) How large are the files (less than 1MB, 10MB, 100MB?)
    3) Can anyone upload, or is there a need for security,
    like a member registration system?
    4) Can anyone administer the files, or a control panel
    that only an "admin" person can access?
    5) Can anyone view the list of files, or members only?
    6) Do the files (or data) need to be protected in a special directory?
    (again ... describe security needs).

  • #5
    Regular Coder BabyJack's Avatar
    Join Date
    Apr 2008
    Location
    Somewhere.
    Posts
    602
    Thanks
    43
    Thanked 6 Times in 6 Posts
    1. About 30 per week
    2. files will be more than 100MB
    3. member Registration form
    4. Only an admin person can access the CP
    5. Anyone
    6. No, however, they have to have a backup in an external file.
    Enlightenment in Coding
    Validate before Posting | Google is your friend for PC Problems | Make sure you have a doctype

  • #6
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Quote Originally Posted by BabyJack View Post
    2. files will be more than 100MB
    This alone will mean you are going to have to find a more advanced solution. And it doesn't appear you are at an advanced level of website creation.

  • #7
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    You could give members (or anyone who you want) upload access to an FTP site. You could easily script the server to reject anything that doesn't end in a .sims2Pack file extension as well.

    Of course, there are other security issues that you have to consider when you set up an open ftp server...

  • #8
    Regular Coder BabyJack's Avatar
    Join Date
    Apr 2008
    Location
    Somewhere.
    Posts
    602
    Thanks
    43
    Thanked 6 Times in 6 Posts
    Code:
    . And it doesn't appear you are at an advanced level of website creation.
    *coughs* www.wifee.missingstudios.com
    Enlightenment in Coding
    Validate before Posting | Google is your friend for PC Problems | Make sure you have a doctype

  • #9
    Regular Coder FWDrew's Avatar
    Join Date
    Apr 2008
    Location
    Missouri
    Posts
    380
    Thanks
    38
    Thanked 45 Times in 43 Posts
    Quote Originally Posted by BabyJack View Post
    Code:
    . And it doesn't appear you are at an advanced level of website creation.
    *coughs* www.wifee.missingstudios.com
    SQL ERROR [ mysql4 ]

    Table 'missings_wifee.phpbb3_config' doesn't exist [1146]
    and another error....
    http://www.wifee.missingstudios.com/media/index.php
    ^^ From your site, figured you might want to know. Also about half the links dont work. Normally, I wouldnnt say anything but since you posted a link to your site I can only assume you wanted some kind of feedback.

    And you should get that coughed looked at, it doesnt sound good.

    Drew

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    So, looking at your specs now, it looks like you should start
    with a PHP/MySQL membership script (many free ones available).
    That will control your user's access. It will also control the admin panel.

    The next step would be the FTP part ... because of the large file size.

    Quote from first post: "...and I am not willing to pay any money for this."

    I think you can find all the scripts you need, for free (using Google).

  • Users who have thanked mlseim for this post:

    BabyJack (05-21-2008)

  • #11
    Regular Coder BabyJack's Avatar
    Join Date
    Apr 2008
    Location
    Somewhere.
    Posts
    602
    Thanks
    43
    Thanked 6 Times in 6 Posts
    Code:
    So, looking at your specs now, it looks like you should start
    with a PHP/MySQL membership script (many free ones available).
    That will control your user's access. It will also control the admin panel.
    
    The next step would be the FTP part ... because of the large file size.
    
    Quote from first post: "...and I am not willing to pay any money for this."
    
    I think you can find all the scripts you need, for free (using Google).
    Google, google, google. Thanks


    *yes i know I am putting messages in code.

    Code:
    FWDrew is an unknown quantity at this point
    	
    Quote:
    Originally Posted by BabyJack View Post
    Code:
    
    . And it doesn't appear you are at an advanced level of website creation.
    
    *coughs* www.wifee.missingstudios.com
    Quote:
    SQL ERROR [ mysql4 ]
    
    Table 'missings_wifee.phpbb3_config' doesn't exist [1146]
    and another error....
    http://www.wifee.missingstudios.com/media/index.php
    ^^ From your site, figured you might want to know. Also about half the links dont work. Normally, I wouldnnt say anything but since you posted a link to your site I can only assume you wanted some kind of feedback.
    
    And you should get that coughed looked at, it doesnt sound good.
    My friend and I are working on the forums. I need to delete the 1,000 tables o.o.

    And yes, some of the links don't work. It has only been up since Sunday.
    Enlightenment in Coding
    Validate before Posting | Google is your friend for PC Problems | Make sure you have a doctype

  • #12
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Quote Originally Posted by BabyJack View Post
    Code:
    . And it doesn't appear you are at an advanced level of website creation.
    *coughs* www.wifee.missingstudios.com
    I was talking about the realm of PHP (this being a PHP forum). If you were at an advanced stage, you wouldn't be asking this question on this forum.


  •  

    Posting Permissions

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