making me crazy..

Started on the old forum in April 2012 · view the original in the archive · old links redirect here

10 replies · 605 views · started 14 years ago · 1 min read

3 participants
icedroplet1987 Senior · 258 posts #1

friends help me in this,

<?php
error_reporting(E_warning);

$time = date("d.m.Y, H:i:s");
$Browser = ' $_SERVER[HTTP_USER_AGENT]';
$ip='$_SERVER[REMOTE_ADDR]';
$desc=trim($_POST['desc']);
$user=trim($_POST['user']);
if(!$desc) $desc="No description available.";
if(!$user) $user="Guest";
// apare input-ul atata timp cat nu e Opera MIni 3.
if (preg_match("/Opera Mini/i", $Browser) && !preg_match("/Opera Mini\/3.0/i", $Browser)) $OperaMini = TRUE;
$no="no";

header("Cache-Control: no-cache, must-revalidate");
header("Content-type: text/html; charset=ISO-8859-1");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\"
\"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";

echo "<head>\n";
include("config.php");

echo "<title>Upload File</title>";
echo "<link rel='stylesheet' href='style.css' type='text/css'/>";
echo "</head>\n";
echo "<body>";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\">";
echo "<tr><td><center><font color='red' size='5'>Hex</font><font color='blue' size='5'>Load</font><br/>First ever site to exchange files with no restrictions at all</center></td></tr></table>";
echo "<div class='hl'>Upload file</div>";

if($_GET[page] !=="add"){
echo "<form method=\"post\" enctype=\"multipart/form-data\" action=\"upload.php?page=add\">";
if ($OperaMini) {
echo "<input type='text' name='file1' size='30'/> <a href='op:fileselect'>Browse files</a><br>";
}
else {
echo "<input type=\"file\" name=\"filetoupload\"><br>";
}
echo "<input type=\"Submit\" name=\"uploadform\" value=\"Upload File\">";
echo "(No file size limit)";
echo "</div>";
echo "<div class=\"hl\">Optional</div>";
echo "<div class=\"txt\"><b><font color=\"green\">User:</font></b>";
echo "<br/><input type=\"text\" value=\"".$COOKIE["HexLoadUser"]."\" name=\"user\" size=\"30\" /><br/>";
echo "<div class=\"txt\"><b><font color=\"green\">Description:</font></b>";
echo "<br/><textarea name=\"desc\" rows=\"4\" cols=\"40\"></textarea><br/>";
echo "<small>Notice: once you submit the file, it will be available to public.</small>";
echo "<br/><b>Please wait while the file is uploaded, it may take several minutes depending by the size of the file and by your internet bandwidth.</b>";
echo "</div>";
echo "</form>";

}

if ($_REQUEST[file1]) {
$file1 = $_REQUEST[file1];
$file1 = explode("=", $file1);
$file_content = $file1[1];
$filename = str_replace("file", "", $file1[0]);

$size = strlen($file_content);

}
else {

$filename = $_FILES['filetoupload']['name'];
$size = $_FILES['filetoupload']['size'];
}
$ext = strrchr($filename,'.');
$truext=str_replace(".","",$ext);
$truext=strtolower($truext);
$ext=strtolower($ext);
$upload_dir=htmlspecialchars("$truext/");

$filename=str_replace(" ","_",$filename);
$filename=str_replace("`","",$filename);
$filename=str_replace("]","",$filename);
$filename=str_replace("[","",$filename);

$filename=str_replace("~","",$filename);
$filename=str_replace("@","",$filename);
$filename=str_replace("#","",$filename);
$filename=str_replace("%","",$filename);
$filename=str_replace("^","",$filename);

$filename=str_replace("*","",$filename);

$filename=str_replace("|","",$filename);
$filename=str_replace("$","",$filename);
$filename=str_replace("<","",$filename);
$filename=str_replace("<","",$filename);
$filename=str_replace(">","",$filename);
$filename=str_replace(">","",$filename);
$filename=str_replace("\"","",$filename);
$filename=str_replace("'","",$filename);
$filename=str_replace("\\","",$filename);

if($_GET['page']=="add"){

if (!$filename)
{
echo "<b>Please select a file for upload.</b><br />";
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}

if (($extlimit == "yes") && (in_array($ext,$limitedext)))
{
echo("Extension <b>$ext</b> was disabled due security reasons.The file was NOT uploaded!<br />");
echo "<br />";
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}

if(strlen($filename)>$lungime_nume)
{
echo "<b><font color=\"red\">Your file name has a name too long.Please rename it!</font></b><br />";
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}

if ($size > $size_bytes)
{
echo "<b><font color=\"red\">Your file size is too big.Maximum allowed is $mb MB.</font></b><br />";
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}

if (file_exists("$upload_dir/$filename"))
{
echo("<b><font color=\"red\">File already exist.Please rename your file!</font></b><br />");
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}

if ($file1) {
if(!is_dir($upload_dir)){mkdir($upload_dir); chmod($upload_dir,0777); copy("htaccess.txt","$upload_dir.htaccess");}

$fp = fopen($upload_dir.$filename, "w") or die("File cannot be saved due server permissions");

fwrite($fp, base64_decode($file_content));
if (fclose($fp)) $Uploaded = TRUE;

}
else {
if(!is_dir($upload_dir)){mkdir($upload_dir); chmod($upload_dir,0777); copy("htaccess.txt","$upload_dir.htaccess");}
move_uploaded_file($_FILES['filetoupload']['tmp_name'], $upload_dir.$filename) or die("Cannot move uploaded file");/// i am getting this condition error.. while it was working fine before , i didnt make any change in any code ever then also it automatically again giving this condition error. its copying file ext. directory, .htaccess but not have to move file.. why??
$Uploaded = TRUE;
}

if ($Uploaded)
{
mysql_query("INSERT INTO hrzshare (banned,file,user,browse,ip,ftype,uploaded,description,size) VALUES ('$no','$filename','$user','$Browser','$ip','$truext','$time','$desc','$size')");
$sql = mysql_query("SELECT * FROM hrzshare WHERE file = '$filename' ");

while($row = mysql_fetch_array($sql)){
$id = $row['id'];}

echo ("<b><font color=\"red\">Your file was uploaded </font><a href=\"file.php?id=$id\">here</a></b><br />
<u>Copy and paste the following code:</u><br />
<textarea name=\"link\" rows=\"5\" cols=\"40\">".$url."/file.php?id=".$id."</textarea><br />");

echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";

die();
}
else
{

echo "<b><font color=\"red\">Unexpected error.Please try again.</font></b><br />";
echo "<br />";
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "</div>";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}

}

echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "</div>";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
echo "</body>";
echo "</html>";

?>
something else Fellow · 2,296 posts #2

try:

if (isset($_REQUEST['file1'])) {

make sure your $_REQUEST[] has got ' ' encasing the string or your causing php errors 🙂

icedroplet1987 Senior · 258 posts #3

something else wrote: try:

if (isset($_REQUEST['file1'])) {

make sure your $_REQUEST[] has got ' ' encasing the string or your causing php errors :)

i did this too, but problem remains same:(

something else Fellow · 2,296 posts #4

try putting: echo "Debug: ".$upload_dir.$filename." "; to make sure your getting the correct filename when uploading (isnt returning blank (iv got similar problem at moment and so has pmbguy))

icedroplet1987 Senior · 258 posts #5

something else wrote: try putting: echo "Debug: ".$upload_dir.$filename." "; to make sure your getting the correct filename when uploading (isnt returning blank (iv got similar problem at moment and so has pmbguy))

yes file name and directory is correct .. filename having that replacement.. its working fine with small files, error with large n no limit error as limit defined to 750M already.. i mean its not coz of memory.. dont know what is wrong..

something else Fellow · 2,296 posts #6

have you checked via ftp to see if folder permissions are set to 777?

something else Fellow · 2,296 posts #8

hmmm maybe its because safe mode is enabled try:

$current = getcwd();
chdir($upload_dir);
move_uploaded_file($_FILES['filetoupload']['tmp_name'], $filename) or die("Cannot move uploaded file");
chdir($current);
icedroplet1987 Senior · 258 posts #9

something else wrote: hmmm maybe its because safe mode is enabled try:

$current = getcwd();
chdir($upload_dir);
move_uploaded_file($_FILES['filetoupload']['tmp_name'], $filename) or die("Cannot move uploaded file");
chdir($current);

problem remains same even after this!!

something else Fellow · 2,296 posts #11

pmbguy wrote: ok, try chmod the folder you are uploading to 755, some servers don't work with 777

the problem is $_FILES['filetoupload']['tmp_name'] is returning blank meaning the file was not getting uploaded into tmp folder

so i created a new temp folder and changed the temp folder in php.ini .... which solved it for ice.... but then it stopped working again soon after

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close