...

View Full Version : Simple Uploader Question



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


<?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?

mlseim
09-05-2011, 01: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".


.

Xaqa
09-05-2011, 04: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.

mlseim
09-05-2011, 07: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.


.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum