Re: [PHP] error messaages - $DOXPath Wrong

2008-12-05 Thread Maciek Sokolewicz

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



RE: [PHP] error messaages - $DOXPath Wrong

2008-12-05 Thread Boyd, Todd M.
 -Original Message-
 From: Maciek Sokolewicz [mailto:[EMAIL PROTECTED]
 Sent: Friday, December 05, 2008 2:07 AM
 To: php-general@lists.php.net; [EMAIL PROTECTED]
 Subject: Re: [PHP] error messaages - $DOXPath Wrong
 
 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.s
 tring.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.

Lots of good points there. I think it's also worth mentioning that
mixing back slashes in file paths with forward slashes is a terrible,
terrible idea. Pick one and stick with it. To be honest, I'm not even
sure Windows-branded PHP is capable of dissecting a local file system
address when it uses forward slashes.

So.. yes, the \xa is being turned into hexadecimal garbage... but if you
continue to have errors after replacing it with \\xa (and doubling up
all of the other back slashes in your paths), try:

C:\\xampp\\htdocs\\dox\\th_dsc_076.jpg

Instead of

C:\\xampp\\htdocs\\dox/th_dsc_076.jpg

HTH,


// Todd

--
PHP General Mailing List (http://www.php.net

Re: [PHP] error messaages - $DOXPath Wrong

2008-12-05 Thread ddg2sailor

First I would like to thank everyone who reponded to this thread. Your all
Great!

I took your advice and made these changes

//Just the relevant lines not in order

$DOXPATH = 'C:\\xampp\\htdocs\\dox\\'

// New DOXPATH 


if (!move_uploaded_file($file['tmp_name'], '$DOXPATH\$file[name]'))

//Fixed line 40 (now 41) ' changed to ' , / change to \ , dont even think I
need that \


//end of code

I sent this code to the sysop of the site and it was in his mail box when he
decided to reformat the system and restore yet another backup. On the bright
side it did cure this issue But the file in question is now a java
script :) , I will never know if this worked cause its no longer used. I
fixxed a few minor error's that I had fixxed before the restore. I had to
check the php files because they were just slightly recoded... It took about
10 mins to fix what I already knew how to fix Now that everything
works... Im not important anymore... Stop talking to me Im trying to do
some work

Well who said life is supposed to be fair?

?
//regards
//Sailor
?


Maciek Sokolewicz-2 wrote:
 
 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
 
 
 

-- 
View this message in context: 
http://www.nabble.com/error-messaages---%24DOXPath-Wrong-tp20848918p20867173.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



Re: [PHP] error messaages - $DOXPath Wrong

2008-12-04 Thread ddg2sailor

This is line 40

if (!move_uploaded_file($file[tmp_name], $DOXPATH/$file[name])) 

Sailor
-- 
View this message in context: 
http://www.nabble.com/error-messaages---%24DOXPath-Wrong-tp20848918p20848948.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