View Full Version : Simple Uploader Question

09-05-2011, 01:16 AM
Here's my code, first:


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

if (!defined("VALID_PHP"))
die('Direct access to this location is not allowed.');

$sort = str_replace("-", " ", $_GET['sort']);
$sort = 'site_votes DESC';

$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;

$return = $sites->submitSite();

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.';
$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">
<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." />
$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";
<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 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>

The problem is when I upload, it doesn't upload the file. It doesn't even give me the thumbs up code. Help?

09-05-2011, 02:15 AM
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".


09-05-2011, 05:08 AM
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.

09-05-2011, 08:57 PM
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.