Strange Upload Problem

This is a discussion on Strange Upload Problem within the PHP Language forums, part of the PHP Programming Forums category; I am creating a php script that I can call from a delphi program, this itself is easy as I ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-06-2004
Ian Hardcastle
 
Posts: n/a
Default Strange Upload Problem

I am creating a php script that I can call from a delphi program, this
itself is easy as I have already done this. The problem lies within
the php script, here is the code that DOESN'T work:

<?
$temp = $_POST['userid'];
$uppath = "users/$temp";
clearstatcache();
if(file_exists($uppath)){
unlink($uppath);
}
if(copy($imgname, $uppath)){
print("done_upload");
}else{
print("failed_upload");
}
?>

KEY: userid will be something like '5.jpg' without quotes, so uppath
will be something like 'users/5.jpg'.

This is the error responce from the script, sorry its in a raw state:

<br />
<b>Warning</b>: copy(users/5.jpg
): failed to open stream: Invalid argument in <b>C:\Program
Files\Apache Group\Apache2\htdocs\messenger\up.php</b> on line
<b>8</b><br />
failed_upload

NOW, if I hardcode the uppath to 'users/5.jpg' NOT using userid to
complete the path this works - Weird, example below:

<?
//$temp = $_POST['userid'];
$uppath = "users/5.jpg";
clearstatcache();
if(file_exists($uppath)){
unlink($uppath);
}
if(copy($imgname, $uppath)){
print("done_upload");
}else{
print("failed_upload");
}
?>


I can't understand why I can hardcode the path, which is the same as
the one made up using the userid, and it works perfect.

The path I make using userid when printed out is correct and the file
exists cos I have checked this using a file_exists() check.

Any help is appreciated

Thanks

Ian
Reply With Quote
  #2 (permalink)  
Old 01-06-2004
Pedro Graca
 
Posts: n/a
Default Re: Strange Upload Problem

Ian Hardcastle wrote:
> I am creating a php script that I can call from a delphi program, this
> itself is easy as I have already done this. The problem lies within
> the php script, here is the code that DOESN'T work:
>
><?
> $temp = $_POST['userid'];


Maybe there's some extra characters in the POST variable
$temp = trim($temp);


> $uppath = "users/$temp";

[snip]
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Reply With Quote
  #3 (permalink)  
Old 01-07-2004
Ian Hardcastle
 
Posts: n/a
Default Re: Strange Upload Problem

Thanks Pedro the trim() function seemed to fix the problem. There must
have been some invalid characters or blank space that didn't show up
when output so the comparison looked the same.

Thanks again, if only all problems were as simple to fix.

Later
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:15 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0