View unanswered posts | View active topics It is currently Tue Dec 12, 2017 5:01 pm



Reply to topic  [ 1 post ] 
 Simple uploader script 
Author Message
Junior Member

Joined: Fri Jun 12, 2009 12:46 am
Posts: 3
Post Simple uploader script
Hi Guys,

I have come across a completly free simple uploader script that i wish to use but i am having some problems with it. The script has 2 files config.php and index.php the a folder for the uploaded files.

now if i put the 2 php files on my root they work fine and upload to the desiginated folder. but because i already have my own website index.php file on the root i need to move the 2 uploader script files into there own folder lets say named UPLOADER and when i do i get errors.

here are the 2 php files for you to see.

CONFIG.PHP

Upload dirs(folders) list
- - - - - - - - - - - - - - - - - -
"images" => array(
"dir" =>"uploads/images",
"password"=>"images",
),
- - - - - - - - - - - - - - - - - -
"images" - just section name (any name you like), it is a key
"name" - the dir(folder) name in select box
"dir" - path to uploaded files
"password" - "dir" password
*/
$upload_dirs = array(
"zips" => array(
"dir" =>"uploads/zips/",
"name" =>"zip file",
"password"=>"to be set",
),
"rar" => array(
"dir" =>"uploads/Zips/",
"name" =>"rar file",
"password"=>"to be set",
),
);
$max_file_size = 500000*1024; //max file upload size (bytes)
?>

INDEX.PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="XHTML namespace" lang="en">
<head>
<title>Script Uploader</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="handmade" />
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
background-color: #DDDDDD;
}
.cnt {
text-align: center;
}
.cnt_welcome {
font-size: 16px;
font-weight: bold;
text-align: center;
}
.cnt_powered {
font-size: 14px;
font-weight: bold;
text-align: center;
}
.cnt_small {
font-size: 12px;
text-align: center;
padding-top: 50px;
}
.head_line {
background-color: #BBBBBB;
}
.main_table {
border: solid 1px #9D9992;
font-size: 13px;
}
h4 {
font-size: 12px;
color: #DD0000;
text-align: center;
}
.button {
border: 1px solid #55555;
font-weight: bold;
}
-->
</style>
</head>
<body>
<?
include("config.php");
function path_options()
{
global $upload_dirs;
$option = "";
foreach ($upload_dirs as $path => $pinfo)
{
$option .= '<option value="'.$path.'">'.$pinfo["name"].'</option>';
}
return $option;
}
function check_vals()
{
global $upload_dirs, $err;
if (!ini_get("file_uploads")) { $err .= "HTTP file uploading is blocked in php configuration file (php.ini). Please, contact to server administrator."; return 0; }
$pos = strpos(ini_get("disable_functions"), "move_uploaded_file");
if ($pos !== false) { $err .= "PHP function move_uploaded_file is blocked in php configuration file (php.ini). Please, contact to server administrator."; return 0; }
if (!isset($_POST["path"]) || (strlen($_POST["path"]) == 0)) { $err .= "Please fill out path"; return 0; }
if (!isset($upload_dirs[$_POST["path"]])) { $err .= "Incorrect path"; return 0; }
if (!isset($_POST["pwd"]) || (strlen($_POST["pwd"]) == 0)) { $err .= "Please fill out password"; return 0; }
elseif ($_POST["pwd"] != $upload_dirs[$_POST["path"]]["password"]) { $err .= "The upload password is incorrect"; return 0; }
if (!isset($_FILES["userfile"])) { $err .= "Empty file"; return 0; }
elseif (!is_uploaded_file($_FILES['userfile']['tmp_name'])) { $err .= "Empty file"; return 0; }
return 1;
}
$err = ""; $status = 0;
if (isset($_POST["upload"])) {
if (check_vals()) {
if (filesize($_FILES["userfile"]["tmp_name"]) > $max_file_size) $err .= "Maximum file size limit: $max_file_size bytes";
else {
if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $upload_dirs[$_POST["path"]]["dir"].$_FILES["userfile"]["name"])) {
$status = 1;
}
else $err .= "There are some errors!";
}
}
}
if (!$status) {
if (strlen($err) > 0) echo "<h4>$err</h4>";
}
else {
echo "<h4>"".$_FILES["userfile"]["name"]."" was successfully uploaded.</h4>";
}
?>
<p class="cnt_welcome"><font color="#000000">Welcome to Panda1rimshots script testing File Uploader
</font></p>
<p class="cnt">« <a href="[url=http://www.bubblegum-web.com/scripter/tester/index.html">Back]Hosting24.com[/url]
to Nitro Scripts</a> «</p>
<p class="cnt">Select your (<b><font color="#FF0000">ZIP</font></b>) or (<font color="#FF0000"><b>RAR</b></font>)
file from the menu: Enter the password: <b><font color="#FF0000">bubblegum</font></b>
then click "<font color="#FF0000"><b>Upload</b></font>" button.

<b><font color="#FF0000">Note</font></b>: Maximum file size:
<?=$max_file_size/1024?>
Kb.</p>
<div align="center"></div>
<form enctype="multipart/form-data" action="index.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="<?=$max_file_size?>" />
<table class="main_table" align="center">
<tr>
<td colspan="2" class="head_line"> </td>
</tr>
<tr>
<td>File Type:</td>
<td><select name="path"><?=path_options()?></select></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pwd" style="width: 217px;" /></td>
</tr>
<tr>
<td>Choose file:</td>
<td><input type="file" name="userfile" style="width: 222px;" /></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="upload" value="Upload" class="button" /></td>
</tr>
</table>
</form>
<p class="cnt_powered">Powered by <a href="EnergyScripts Website Design, Development, Maintenance" target="_blank">Bubblegum-web.com</a>
<p class="cnt_powered"><img src="ad1.gif" width="360" height="450">
</body>
</html>

ERROR MESSAGE REPORT

Warning: move_uploaded_file(uploads/zips/ad1.zip) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/bubblegu/public_html/uploads/index.php on line 87

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpIEmxkg' to 'uploads/zips/ad1.zip' in /home/bubblegu/public_html/uploads/index.php on line 87

There are some errors!

i just dont get it? when the 2 php files are in root they work, but when they are in a folder they dont?..oh!! and when this is tested on xampp on my pc in a folder it works fine?


Sat Jan 30, 2010 6:12 am
Report this post
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.