473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Uploading using POST method

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:pa**@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 ?

<?php
$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
Nov 19 '07 #1
5 1837
On Nov 19, 10:10 am, "Bob Bedford" <b...@bedford.comwrote:
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 ?

<?php
$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'].
Nov 19 '07 #2

"ZeldorBlat" <ze********@gmail.coma écrit dans le message de news:
f8**********************************...oglegroups.com...
On Nov 19, 10:10 am, "Bob Bedford" <b...@bedford.comwrote:
>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 ?

<?php
$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
Nov 19 '07 #3
Bob Bedford:
http://username:pa**@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
Nov 19 '07 #4

"ZeldorBlat" <ze********@gmail.coma écrit dans le message de news:
f8**********************************...oglegroups.com...
On Nov 19, 10:10 am, "Bob Bedford" <b...@bedford.comwrote:
>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 ?

<?php
$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'
?
Nov 19 '07 #5
"Bob Bedford" <bo*@bedford.comwrote:
>>>
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, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 20 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dickiedyce | last post by:
Hi there. I've spent the weekend getting ever more frustrated, trying to get an upload file function working on a website. The site is hosted by a company called oneandone. They're using PHP...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
2
by: tshad | last post by:
I have a page that I am using for multiple uses that includes reposting of the page as well as going to another page where the "form" tag would be something like: <form id="something"...
2
by: FusionGuy | last post by:
I've created a file uploading handler, implemented as an httpHandler. Each time I attempt to upload a file, or files, my HttpContext.Request.Files property never contains the files that were...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
0
Fary4u
by: Fary4u | last post by:
Hi Guys i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem hidden file value, multiple form or popup uploading. 1-...
1
by: WeCi2i | last post by:
Okay, I have a problem that has been stumping me for weeks. I have tried many different solutions and this is pretty much my last resort. I have seen a lot of good answers give here so I figured I...
1
by: seeing | last post by:
hello :) i have managed to get my php to work as in, an uploader user page 1) upload.php ||| amount of files to be uploaded <html> <head> <title>Upload_Amount</title>
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
by: Piotrekk | last post by:
Hi My application is uploading the file to the ASP script. I am dealing with situation where ASP script is not interested in receiving a file. I simulate this by returning from ASP script: ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.