Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #4250 > unrolled thread
| Started by | Leo Decap <fcatus@yahoo.com> |
|---|---|
| First post | 2012-01-07 15:06 +0100 |
| Last post | 2012-01-10 13:02 -0600 |
| Articles | 12 — 8 participants |
Back to article view | Back to comp.lang.php
form - file - sumple question Leo Decap <fcatus@yahoo.com> - 2012-01-07 15:06 +0100
Re: form - file - sumple question Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-07 09:09 -0500
Re: form - file - sumple question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-07 15:40 +0100
Re: form - file - sumple question Luuk <Luuk@invalid.lan> - 2012-01-07 15:40 +0100
Re: form - file - sumple question Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-07 09:53 -0500
Re: form - file - sumple question Luuk <Luuk@invalid.lan> - 2012-01-07 16:24 +0100
Re: form - file - sumple question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-07 15:39 +0100
Re: form - file - sumple question "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-01-07 16:10 +0100
Re: form - file - sumple question Leo Decap <fcatus@yahoo.com> - 2012-01-07 16:24 +0100
Re: form - file - sumple question Jonathan Stein <jstein@image.dk> - 2012-01-08 16:41 +0100
Re: form - file - sumple question "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-01-09 09:38 +0100
Re: form - file - sumple question "Peter H. Coffin" <hellsop@ninehells.com> - 2012-01-10 13:02 -0600
| From | Leo Decap <fcatus@yahoo.com> |
|---|---|
| Date | 2012-01-07 15:06 +0100 |
| Subject | form - file - sumple question |
| Message-ID | <4f08514c$0$5038$ba620e4c@news.skynet.be> |
Hi, I have a form which users can fill in. If the user hasn't filled in a required field, the form reloads after the Submit with all the data the user has entered filled in (and the opportunity to fill in the missing data). I get the data through $_POST and echo the allready filled in data on the form. Easy. I have 1 field - type File - where the user can choose a photo to upload. On reload of the form, I would love to see the entered data (path?) reappear, but I can't figure out how to do this.......... Any help here would be appreciated. Leo
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-01-07 09:09 -0500 |
| Message-ID | <je9jmd$qjl$1@dont-email.me> |
| In reply to | #4250 |
On 1/7/2012 9:06 AM, Leo Decap wrote: > Hi, > > I have a form which users can fill in. > If the user hasn't filled in a required field, the form reloads after > the Submit with all the data the user has entered filled in (and the > opportunity to fill in the missing data). > I get the data through $_POST and echo the allready filled in data on > the form. Easy. > > I have 1 field - type File - where the user can choose a photo to upload. > On reload of the form, I would love to see the entered data (path?) > reappear, but I can't figure out how to do this.......... > > Any help here would be appreciated. > > Leo You can't do it. For security reasons, HTTP will now allow FILE fields to be filled in. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-01-07 15:40 +0100 |
| Message-ID | <2259515.FRqVoOGUtd@PointedEars.de> |
| In reply to | #4251 |
Jerry Stuckle wrote: > On 1/7/2012 9:06 AM, Leo Decap wrote: >> I have 1 field - type File - where the user can choose a photo to upload. >> On reload of the form, I would love to see the entered data (path?) >> reappear, but I can't figure out how to do this.......... >> >> Any help here would be appreciated. > > You can't do it. For security reasons, HTTP will now allow FILE fields > to be filled in. s/HTTP/(X)HTML/ s/now/not/ -- PointedEars
[toc] | [prev] | [next] | [standalone]
| From | Luuk <Luuk@invalid.lan> |
|---|---|
| Date | 2012-01-07 15:40 +0100 |
| Message-ID | <b42mt8-398.ln1@luuk.invalid.lan> |
| In reply to | #4251 |
On 07-01-2012 15:09, Jerry Stuckle wrote: > On 1/7/2012 9:06 AM, Leo Decap wrote: >> Hi, >> >> I have a form which users can fill in. >> If the user hasn't filled in a required field, the form reloads after >> the Submit with all the data the user has entered filled in (and the >> opportunity to fill in the missing data). >> I get the data through $_POST and echo the allready filled in data on >> the form. Easy. >> >> I have 1 field - type File - where the user can choose a photo to upload. >> On reload of the form, I would love to see the entered data (path?) >> reappear, but I can't figure out how to do this.......... >> >> Any help here would be appreciated. >> >> Leo > > You can't do it. For security reasons, HTTP will now allow FILE fields > to be filled in. > I suggest you (Leo) to take a look at JavaScript, to do simple checks if a field is filled in or not. For the complicated checks, you might still want to use some PHP stuff afterwards.... -- Luuk
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-01-07 09:53 -0500 |
| Message-ID | <je9mac$88i$1@dont-email.me> |
| In reply to | #4254 |
On 1/7/2012 9:40 AM, Luuk wrote: > On 07-01-2012 15:09, Jerry Stuckle wrote: >> On 1/7/2012 9:06 AM, Leo Decap wrote: >>> Hi, >>> >>> I have a form which users can fill in. >>> If the user hasn't filled in a required field, the form reloads after >>> the Submit with all the data the user has entered filled in (and the >>> opportunity to fill in the missing data). >>> I get the data through $_POST and echo the allready filled in data on >>> the form. Easy. >>> >>> I have 1 field - type File - where the user can choose a photo to upload. >>> On reload of the form, I would love to see the entered data (path?) >>> reappear, but I can't figure out how to do this.......... >>> >>> Any help here would be appreciated. >>> >>> Leo >> >> You can't do it. For security reasons, HTTP will now allow FILE fields >> to be filled in. >> > > I suggest you (Leo) to take a look at JavaScript, to do simple checks if > a field is filled in or not. > > For the complicated checks, you might still want to use some PHP stuff > afterwards.... > I don't think javascript will allow it either, Luuk. It would be a huge security concern. Can you imagine what hackers could do if they could put an invisible FILE field on a page and get any file on your system without your knowledge? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Luuk <Luuk@invalid.lan> |
|---|---|
| Date | 2012-01-07 16:24 +0100 |
| Message-ID | <gm4mt8-eu8.ln1@luuk.invalid.lan> |
| In reply to | #4255 |
On 07-01-2012 15:53, Jerry Stuckle wrote: > On 1/7/2012 9:40 AM, Luuk wrote: >> On 07-01-2012 15:09, Jerry Stuckle wrote: >>> On 1/7/2012 9:06 AM, Leo Decap wrote: >>>> Hi, >>>> >>>> I have a form which users can fill in. >>>> If the user hasn't filled in a required field, the form reloads after >>>> the Submit with all the data the user has entered filled in (and the >>>> opportunity to fill in the missing data). >>>> I get the data through $_POST and echo the allready filled in data on >>>> the form. Easy. >>>> >>>> I have 1 field - type File - where the user can choose a photo to >>>> upload. >>>> On reload of the form, I would love to see the entered data (path?) >>>> reappear, but I can't figure out how to do this.......... >>>> >>>> Any help here would be appreciated. >>>> >>>> Leo >>> >>> You can't do it. For security reasons, HTTP will now allow FILE fields >>> to be filled in. >>> >> >> I suggest you (Leo) to take a look at JavaScript, to do simple checks if >> a field is filled in or not. >> >> For the complicated checks, you might still want to use some PHP stuff >> afterwards.... >> > > I don't think javascript will allow it either, Luuk. It would be a huge > security concern. > > Can you imagine what hackers could do if they could put an invisible > FILE field on a page and get any file on your system without your > knowledge? > Yeah, i can imaginge, but, in the original question, it started with: "If the user hasn't filled in a required field" and THAT is something you can check using javascript without ANY security issues. -- Luuk
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-01-07 15:39 +0100 |
| Message-ID | <1935580.aqSPkdTlGX@PointedEars.de> |
| In reply to | #4250 |
Leo Decap wrote: > I have 1 field - type File - where the user can choose a photo to upload. > On reload of the form, I would love to see the entered data (path?) > reappear, but I can't figure out how to do this.......... type="file" inputs are user-write only. PointedEars -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-01-07 16:10 +0100 |
| Message-ID | <9mr5jhFbh8U1@mid.uni-berlin.de> |
| In reply to | #4250 |
Am 07.01.2012 15:06, schrieb Leo Decap: > Hi, > ---cut > I have 1 field - type File - where the user can choose a photo to > upload. > On reload of the form, I would love to see the entered data > (path?) reappear, but I can't figure out how to do this.......... > > Any help here would be appreciated. > > Leo No way, as has been said. If it were possible, you could put the element into a display:none block, set contents to what you want (/etc/passwd in *nix), and steal private files. /Str.
[toc] | [prev] | [next] | [standalone]
| From | Leo Decap <fcatus@yahoo.com> |
|---|---|
| Date | 2012-01-07 16:24 +0100 |
| Message-ID | <4f08639b$0$5055$ba620e4c@news.skynet.be> |
| In reply to | #4250 |
Op 7/01/2012 15:06, Leo Decap schreef: > Hi, > > I have a form which users can fill in. > If the user hasn't filled in a required field, the form reloads after > the Submit with all the data the user has entered filled in (and the > opportunity to fill in the missing data). > I get the data through $_POST and echo the allready filled in data on > the form. Easy. > > I have 1 field - type File - where the user can choose a photo to upload. > On reload of the form, I would love to see the entered data (path?) > reappear, but I can't figure out how to do this.......... > > Any help here would be appreciated. > > Leo Hi, thanks everyone, I was afraid that "no way" was the answer... Leo
[toc] | [prev] | [next] | [standalone]
| From | Jonathan Stein <jstein@image.dk> |
|---|---|
| Date | 2012-01-08 16:41 +0100 |
| Message-ID | <4f09b939$0$281$14726298@news.sunsite.dk> |
| In reply to | #4258 |
Den 07-01-2012 16:24, Leo Decap skrev:
> thanks everyone, I was afraid that "no way" was the answer...
Well, it's a bit more complicated, but you can do something to avoid
that the user has to find the file again.
On the first POST, save the file in a temporary location and include a
hidden field with the file id in the new form, you generate.
Then you should also make a "delete" checkbox or button to let the user
remove the file again, and you must clean up the temporary files once in
a while.
Regards
Jonathan
[toc] | [prev] | [next] | [standalone]
| From | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| Date | 2012-01-09 09:38 +0100 |
| Message-ID | <jee91o$g00$1@dont-email.me> |
| In reply to | #4250 |
El 07/01/2012 15:06, Leo Decap escribió/wrote:
> I have a form which users can fill in.
> If the user hasn't filled in a required field, the form reloads after
> the Submit with all the data the user has entered filled in (and the
> opportunity to fill in the missing data).
> I get the data through $_POST and echo the allready filled in data on
> the form. Easy.
>
> I have 1 field - type File - where the user can choose a photo to upload.
> On reload of the form, I would love to see the entered data (path?)
> reappear, but I can't figure out how to do this..........
This approach hits against two walls:
1. The $_FILES array does not contain the original path, mainly because
the browser does not send it to the server.
2. Most browsers ignore pre-filled <input type="file"> elements.
Additionally, you have no control about the uploaded file size until the
file is actually received. If you force the user to upload the file
again and it happens to be a large file, your form can become pretty
unusable.
You need to use a different technique. The simplest one is to move
successfully uploaded files to a temporary location you control and link
them to your form through a reasonably large random ID (so it cannot be
guessed) that can be transmitted through a set of <input type="hidden">
fields.
E.g., if the original $_FILES entry is this:
array(1) {
["avatar"]=>
array(5) {
["name"]=>
string(10) "Logo01.gif"
["type"]=>
string(9) "image/gif"
["tmp_name"]=>
string(27) "C:\WINDOWS\Temp\php1728.tmp"
["error"]=>
int(0)
["size"]=>
int(732)
}
}
... you can use uniqid('tmp_') to generate a random name and save your
file as:
C:\Sites\example.com\temp\tmp_4f0aa7072cb3e
... and add this to your form:
<input type="hidden" name="avatar[id]" value="tmp_4f0aa7072cb3e">
<input type="hidden" name="avatar[name]" value="Logo01.gif">
<input type="hidden" name="avatar[type]" value="image/gif">
When all the entered data is correct, you can move the temporary file to
its definitive location.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[toc] | [prev] | [next] | [standalone]
| From | "Peter H. Coffin" <hellsop@ninehells.com> |
|---|---|
| Date | 2012-01-10 13:02 -0600 |
| Message-ID | <slrnjgp2q4.51n.hellsop@nibelheim.ninehells.com> |
| In reply to | #4250 |
On Sat, 07 Jan 2012 15:06:10 +0100, Leo Decap wrote: > Hi, > > I have a form which users can fill in. > If the user hasn't filled in a required field, the form reloads after > the Submit with all the data the user has entered filled in (and the > opportunity to fill in the missing data). > I get the data through $_POST and echo the allready filled in data on > the form. Easy. > > I have 1 field - type File - where the user can choose a photo to upload. > On reload of the form, I would love to see the entered data (path?) > reappear, but I can't figure out how to do this.......... At this point, the file is already uploaded. THAT can be indicated, though. The php script never even knows what the path was in the first place, so it can't possibly pre-fill a re-display of the form. -- A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web