error messaages - $DOXPath Wrong

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

Here are the error messages:

Warning: move_uploaded_file(C: mpp\htdocs\dox/th_dsc_076.jpg)
[function.move-uploaded-file]: failed to open stream: Invalid argument in
C:\xampp\htdocs\dox.php on line 40

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
'C:\xampp\tmp\php2F.tmp' to 'C: mpp\htdocs\dox/th_dsc_076.jpg' in
C:\xampp\htdocs\dox.php on line 40

Warning: Cannot modify header information - headers already sent by (output
started at C:\xampp\htdocs\dox.php:40) in
C:\xampp\htdocs\include\bittorrent.php on line 478

Il make this as painless as possiable.... I know the third error can be
caused by a dangling white space.. this time it isnt.

This happens when a user uploads a 'dox file. Now we can download them all
we want.
The file Uploads to the right dir : 'C:\xampp\tmp\php2F.tmp' 
But when It tries to copy.. it tries to copy from this dir: C:
mpp\htdocs\dox/th_dsc_076.jpg
And tries to copy to this dir : 'C: mpp\htdocs\dox/th_dsc_076.jpg' 

the correct dirs are c:\xampp\tmp and c:\xampp\dox

//code that kicked my butt

<?
require "include/bittorrent.php";

dbconn(false);

loggedinorreturn();

if (get_user_class() < UC_USER)
stderr("Error" , "Permission denied.");

if ($_SERVER["REQUEST_METHOD"] == "POST")
{

$file = $_FILES['file'];

if (!$file || $file["size"] == 0 || $file["name"] == "")
stderr("Error", "Nothing received! The selected file may have been too
large." );

if (file_exists("$DOXPATH/$file[name]"))
stderr("Error", "A file with the name ".htmlspecialchars($file['name'])."
already exists!" );

$title = trim($_POST["title"]);
if ($title == "")
{
$title = substr($file["name"], 0, strrpos($file["name"], "."));
if (!$title)
$title = $file["name"];
}

$r = mysql_query("SELECT id FROM dox WHERE title=" . sqlesc($title)) or
sqlesc();
if (mysql_num_rows($r) > 0)
stderr("Error", "A file with the title ", "".htmlspecialchars($title)."
already exists!");

$url = $_POST["url"];

if ($url != "")
if (substr($url, 0, 7) != "http://"; && substr($url, 0, 6) != "ftp://";)
stderr("Error", "The URL ", "" . htmlspecialchars($url) . " does not seem to
be valid.");

if (!move_uploaded_file($file["tmp_name"], "$DOXPATH/$file[name]"))
stderr("Error", "Failed to move uploaded file. You should contact an
administrator about this error.");

setcookie("doxurl", $url, 0x7fffffff);

$title = sqlesc($title);
$filename = sqlesc($file["name"]);

$uppedby = $CURUSER["id"];
$size = $file["size"];
$url = sqlesc($url);

mysql_query("INSERT INTO dox (title, filename, added, uppedby, size, url)
VALUES($title, $filename, NOW(), $uppedby, $size, $url)") or sqlerr();

header("Location: dox.php");
die;
}

	//if (get_user_class() >= UC_MODERATOR || $a["uppedby"] == $CURUSER["id"])
		//{
			$delete = $HTTP_GET_VARS["delete"];
			if (is_valid_id($delete))
				{
					$r = mysql_query("SELECT filename,uppedby FROM dox WHERE id=$delete")
or sqlerr(__FILE__, __LINE__);
					if (mysql_num_rows($r) == 1)
						{
							$a = mysql_fetch_assoc($r);
							if (get_user_class() >= UC_MODERATOR || $a["uppedby"] ==
$CURUSER["id"])
								{
									mysql_query("DELETE FROM dox WHERE id=$delete") or sqlerr(__FILE__,
__LINE__);
									if (!unlink("$DOXPATH/$a[filename]"))
									stderr("Warning", "Unable to unlink file:", "".$a['filename']." 
You should contact an administrator about this error.");
								}
						}
				}
		//}

stdhead("Dox");

//print("<h1>"._("Dox")."</h1>\n");
print("<h1>Dox</h1>\n");

$res = mysql_query("SELECT * FROM dox ORDER BY added DESC") or sqlerr();
if (mysql_num_rows($res) == 0)
print("<p>Sorry, nothing here pal :(</p>");
else
{
print("<p><table border=1 cellspacing=0 width=750 cellpadding=5>\n");
print("<tr><td class=colhead align=left>Title</td><td
class=colhead>Date</td><td class=colhead>Time</td><td
class=colhead>Size</td><td class=colhead>Hits</td><td class=colhead>Upped
by</td></tr>\n");

$mod = get_user_class() >= UC_MODERATOR;

while ($arr = mysql_fetch_assoc($res))
{
$r = mysql_query("SELECT username FROM users WHERE id=$arr[uppedby]") or
sqlerr();
$a = mysql_fetch_assoc($r);
$FILELINK = $GLOBALS['DEFAULTBASEURL']."/getdox.php/".str_replace(" ","%20"
, $arr[filename]);
$title = "<td align=left> .$FILELINK. " . $arr[title] . " " .
($mod || $arr["uppedby"] == $CURUSER["id"] ? "  ?delete=$arr[id] [Delete] "
: "") ."</td>\n";
$added = "<td>" . substr($arr["added"], 0, 10) . "</td><td>" .
substr($arr["added"], 10) . "</td>\n";
$size = "<td>" . mksize($arr['size']) . "</td>\n";
$hits = "<td>" . number_format($arr['hits']) . "</td>\n";
$uppedby = "<td> .$GLOBALS['DEFAULTBASEURL']. $a[username] </td>\n";
print("<tr>$title$added$size$hits$uppedby</tr>\n");
}
print("</table></p>\n");
print("<p>Files are automatically deleted after 14 days...This is not in
place...</p>\n");
}

if (get_user_class() >= UC_UPLOADER)
{
$url = $HTTP_COOKIE_VARS["doxurl"];
$maxfilesize = ini_get("upload_max_filesize");
begin_main_frame();
begin_frame("Upload", true);
print("<form enctype=multipart/form-data method=post action=?>\n");
print("<table class=main border=1 cellspacing=0 width=700
cellpadding=5>\n");
print("<tr><td class=rowhead>File</td><td align=left><input type=file
name=file size=60><br>(Maximum file size: ".$maxfilesize.")</td></tr>\n");
print("<tr><td class=rowhead>Title</td><td align=left><input type=text
name=title size=60><br>(Optional, taken from file name if not
specified.)</td></tr>\n");

/*
print("<tr><td class=rowhead>Download URL</td><td align=left><input
type=text name=url size=60 value=\"$url\"><br><table width=340 ".
"class=main border=0 cellspacing=0 cellpadding=0><tr><td
class=embedded>(Optional, specifies a primary FTP/HTTP download location.
You can substitute ".
"the file name part with an asterisk (*), e.g.
http://www.URSITE.com/files/*)</td>&...\n");
*/
print("<tr><td colspan=2 align=center><input type=submit value=Upload file
class=btn></td></tr>\n");
print("</table>\n");
print("</form>\n");
end_frame();
end_main_frame();
}

stdfoot();
?>

//end

Sorry its so long.... But this thing has me beat. I was trying to cross it
with this line from another piece of code that does it fact know the right
dir.... with no luck:

//working code

$file = "$DOXPATH/$arr[filename]";

//end

Maybe its apples and oranges
-- 
View this message in context: http://www.nabble.com/error-messaages---%24DOXPath-Wrong-tp20848918p20848918.html
Sent from the PHP - General mailing list archive at Nabble.com.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux