Uploading using POST method
Uploading using POST method
am 19.11.2007 16:10:00 von Bob Bedford
Hi all,
I've to accept a file that is sent using a POST method.
The file will be sent using this URL:
http://username:pass@www.mysite.com/upload.php
How can I retrieve the username and passord and rename the file ? Should I
use substring using the URI ? Pseudocode below is the best way to do so ?
$user = substr($_SERVER['REQUEST_URI'],pos('//'),pos(':'));
$pass = substr($_SERVER['REQUEST_URI'],pos(':'),pos('@'));
$userid = select userid where user = $user and pass=$pass.
renamefile($_FILES['userfile']['tmp_name'],$userid)
?>
Thanks for help.Bob
Re: Uploading using POST method
am 19.11.2007 16:14:57 von zeldorblat
On Nov 19, 10:10 am, "Bob Bedford" wrote:
> Hi all,
>
> I've to accept a file that is sent using a POST method.
>
> The file will be sent using this URL:
>
> http://username:p...@www.mysite.com/upload.php
>
> How can I retrieve the username and passord and rename the file ? Should I
> use substring using the URI ? Pseudocode below is the best way to do so ?
>
>
> $user = substr($_SERVER['REQUEST_URI'],pos('//'),pos(':'));
> $pass = substr($_SERVER['REQUEST_URI'],pos(':'),pos('@'));
> $userid = select userid where user = $user and pass=$pass.
> renamefile($_FILES['userfile']['tmp_name'],$userid)
> ?>
>
> Thanks for help.Bob
The username will be in $_SERVER['PHP_AUTH_USER'] and the password
will be in $_SERVER['PHP_AUTH_PW'].
Re: Uploading using POST method
am 19.11.2007 16:28:27 von Bob Bedford
"ZeldorBlat" a écrit dans le message de news:
f8e2a53c-00bf-4a21-951c-7395594478e7@a28g2000hsc.googlegroup s.com...
> On Nov 19, 10:10 am, "Bob Bedford" wrote:
>> Hi all,
>>
>> I've to accept a file that is sent using a POST method.
>>
>> The file will be sent using this URL:
>>
>> http://username:p...@www.mysite.com/upload.php
>>
>> How can I retrieve the username and passord and rename the file ? Should
>> I
>> use substring using the URI ? Pseudocode below is the best way to do so ?
>>
>>
>> $user = substr($_SERVER['REQUEST_URI'],pos('//'),pos(':'));
>> $pass = substr($_SERVER['REQUEST_URI'],pos(':'),pos('@'));
>> $userid = select userid where user = $user and pass=$pass.
>> renamefile($_FILES['userfile']['tmp_name'],$userid)
>> ?>
>>
>> Thanks for help.Bob
>
> The username will be in $_SERVER['PHP_AUTH_USER'] and the password
> will be in $_SERVER['PHP_AUTH_PW'].
>
argh !!! too simple...
thanks for help.
Bob
Re: Uploading using POST method
am 19.11.2007 16:41:47 von John Dunlop
Bob Bedford:
> http://username:pass@www.mysite.com/upload.php
Passing secrets in URLs is unsafe, RFC3986 deprecates "user:password"
in all URLs, and RFC2616 does not allow "user:password".
--
Jock
Re: Uploading using POST method
am 19.11.2007 17:06:09 von Bob Bedford
"ZeldorBlat" a écrit dans le message de news:
f8e2a53c-00bf-4a21-951c-7395594478e7@a28g2000hsc.googlegroup s.com...
> On Nov 19, 10:10 am, "Bob Bedford" wrote:
>> Hi all,
>>
>> I've to accept a file that is sent using a POST method.
>>
>> The file will be sent using this URL:
>>
>> http://username:p...@www.mysite.com/upload.php
>>
>> How can I retrieve the username and passord and rename the file ? Should
>> I
>> use substring using the URI ? Pseudocode below is the best way to do so ?
>>
>>
>> $user = substr($_SERVER['REQUEST_URI'],pos('//'),pos(':'));
>> $pass = substr($_SERVER['REQUEST_URI'],pos(':'),pos('@'));
>> $userid = select userid where user = $user and pass=$pass.
>> renamefile($_FILES['userfile']['tmp_name'],$userid)
>> ?>
>>
>> Thanks for help.Bob
>
> The username will be in $_SERVER['PHP_AUTH_USER'] and the password
> will be in $_SERVER['PHP_AUTH_PW'].
>
In fact not soo easy...how to get the filename ?
In the case of a form, you get the control name for getting the file like
this:
$_FILES['formname']['tmp_name']
But since there is no form, what the name I've to put in place of 'formname'
?
Re: Uploading using POST method
am 20.11.2007 07:44:15 von Tim Roberts
"Bob Bedford" wrote:
>>>
>>> I've to accept a file that is sent using a POST method.
>>>
>>> The file will be sent using this URL:
>>>
>>> http://username:p...@www.mysite.com/upload.php
>...
>In fact not soo easy...how to get the filename ?
>
>In the case of a form, you get the control name for getting the file like
>this:
>$_FILES['formname']['tmp_name']
>
>But since there is no form, what the name I've to put in place of 'formname'
>?
If you plan to upload a file using a POST request, then your POST request
has to SIMULATE a form. The POST data will include the file's data as a
named field, just like a form would.
Only you know the name of the field, of course.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.