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
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Simple Uploader Question

    Here's my code, first:

    PHP Code:
    <?php

    /**
     * Home.php
     * @author starr-gaming.com
     * @copyright 2010
     */

    if (!defined("VALID_PHP"))
        die(
    'Direct access to this location is not allowed.');
        
    if(isset(
    $_GET['sort']))
        
    $sort str_replace("-"" "$_GET['sort']);
    else
        
    $sort 'site_votes DESC';
     
    if(isset(
    $_GET['loggedin']))
        
    $msg_info 'You have logged in.';

    $rows $sites->getSites(array("field"=>"site_active""value"=>"Yes"), $sort);
    $i = (intval($_GET['p']) * intval($_GET['ipp'])) - intval($_GET['ipp']);
    if(
    $i 0$i 1;

    if(isset(
    $_POST['submit']))
    {
        
    $return $sites->submitSite();
        if(
    $return)
            
    redirect("/index.php?page=home&siteadded=1");
    }

    if(isset(
    $_GET['siteadded']))
    {
        if(
    $settings->set['site_admin_site_activation'] == 'On')
            
    $msg_ok 'Your site has been added.  You site will be shown once an administrator approves it.';
        else
            
    $msg_ok 'Your site has been added.  It is now visible on the site.';
    }
    ?>
    <?php display_message
    (); ?>
    <h1><?php echo $page_title?></h1>
            <div class="right">
    <form action="/index.php?page=home" enctype="multipart/form-data" method="post">
        <table class="box">
            <tbody>
                <tr>
    <fieldset>
                        <h2>Browse for your file:<em> required</em></h2>
                        <div class="file_input_div">
                          <input type="button" value="Browse&nbsp;&nbsp;»" class="file_input_button" />
                          <input type="file" name="site_url" class="file_input_hidden" onchange="javascript: document.getElementById('fileName').value = this.value" /></div>       
                        <input type="text" id="fileName" class="file_input_textbox" readonly="readonly" />
                        <img src="/images/info.png" class="tooltip" title="The URL to your site, eg: www.yoursite.com." />
    <?php
    $target_path 
    "uploads/";

    $target_path $target_path basename$_FILES['site_url']['name']); 

    if(
    move_uploaded_file($_FILES['site_url']['tmp_name'], $target_path))
     {
        echo 
    "The file ".  basename$_FILES['site_url']['name']). 
        
    " has been uploaded";
    }
    ?>
    </fieldset>            
    </tr>
                <tr>
    <fieldset>
                        <h2>What are you uploading?<em> optional</em></h2>
                        <input id="name" name="site_description" size="30" type="text" class="input_textbox" value="" />
                        <img src="/images/info.png" class="tooltip" title="Tell us a little about what your uploading." />
                    </fieldset>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                                    <fieldset class="buttons">
                      <input type="hidden" name="form_key" id="form_key" value="<?php echo $_SESSION['form_key']; ?>" />
                      <button id="upload_button" name="submit" type="submit" value="Upload Now&nbsp;&nbsp;»">Upload Now&nbsp;&nbsp;»</button>
                    </fieldset>
                </tr>
            </tfoot>
        </table>
    </form>
    </div>
    The problem is when I upload, it doesn't upload the file. It doesn't even give me the thumbs up code. Help?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Do you get just a blank white screen with nothing at all?

    If so, you have a PHP error occurring and you have error reporting turned off.

    Let us know what you mean by "not working".


    .

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts
    By not working I meant, the file selected was not uploading and I didn't have a blank screen but the successful message didn't show and after later checking the upload folder the file was never uploaded. Sorry wasn't very descriptive.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    My suggestion is to only deal with the multi-part form and the actual file upload.
    Make a safe copy of what you have now, and strip it all down to those two parts.
    Get rid of all the sort, logged-in, is it PHP, admin .. etc.

    Get the upload working first, then deal with the other things.


    .


  •  

    Posting Permissions

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