Re: error messaages - $DOXPath Wrong

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

 



ddg2sailor wrote:
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.");
 [SNIP]


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

Ok, first of all, stop pasting entire pages of code in here when they have absolutely nothing to do with the problem. An error on line x almost *NEVER* has anything to do with *anything* on page > 41. So, just... don't.

Next: "Unable to move
'C:\xampp\tmp\php2F.tmp' to 'C: mpp\htdocs\dox/th_dsc_076.jpg'" actually tells you what's going wrong: 1. It can't move the file from an existing place to a place with a path that is invalid. "C: mpp\" is an invalid path on windows. Of course you didn't include the definition of $DOXPath for us, but I bet it looks like:
$DOXPath = "C:\xampp\htdocs\dox";
Now, you're using double quotes here (for no good reason), which means it interprets all escape sequences. What do we do? In the PHP docs lookup escape sequences: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double

Note that:
\x[0-9A-Fa-f]{1,2} the sequence of characters matching the regular expression is a character in hexadecimal notation You have an expression which is basically the same as: 'C:'."\xa".'ampp\htdocs\dox'; where the first and last part work as you intended, but the second one gets replaced by the char with ordinal 10 (which is a space. A in hexadecimal notation is 10 in decimal).

Fix your definition of it (ie. use SINGLE quotes, or double escape it to look like \\xa so the interpreter won't see it as a special escape sequence anymore.

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