Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17832 > unrolled thread
| Started by | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| First post | 2018-12-14 12:44 -0800 |
| Last post | 2018-12-16 12:45 -0500 |
| Articles | 20 — 7 participants |
Back to article view | Back to comp.lang.php
Cannot retrieve error related to a specific file upload, in a 3-part input file blo Dan Campbell <dcwhatthe@gmail.com> - 2018-12-14 12:44 -0800
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Luuk <luuk@invalid.lan> - 2018-12-14 22:02 +0100
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Dan Campbell <dcwhatthe@gmail.com> - 2018-12-14 13:45 -0800
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2018-12-14 17:07 -0500
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Luuk <luuk@invalid.lan> - 2018-12-15 11:15 +0100
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Dan Campbell <dcwhatthe@gmail.com> - 2018-12-15 05:50 -0800
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Luuk <luuk@invalid.lan> - 2018-12-15 16:03 +0100
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Dan Campbell <dcwhatthe@gmail.com> - 2018-12-15 09:42 -0800
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Luuk <luuk@invalid.lan> - 2018-12-15 20:01 +0100
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Arno Welzel <usenet@arnowelzel.de> - 2018-12-16 02:11 +0100
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Luuk <luuk@invalid.lan> - 2018-12-16 14:22 +0100
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Dan Campbell <dcwhatthe@gmail.com> - 2018-12-16 11:05 -0800
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Dan Campbell <dcwhatthe@gmail.com> - 2018-12-16 11:02 -0800
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-12-16 23:30 +0100
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Dan Campbell <dcwhatthe@gmail.com> - 2018-12-16 15:15 -0800
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Dan Campbell <dcwhatthe@gmail.com> - 2018-12-17 07:01 -0800
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Dan Campbell <dcwhatthe@gmail.com> - 2019-01-29 07:06 -0800
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo bill <william@TechServSys.com> - 2019-01-30 06:43 -0500
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Dan Campbell <dcwhatthe@gmail.com> - 2018-12-14 13:42 -0800
Re: Cannot retrieve error related to a specific file upload, in a 3-part input file blo Jerry Stuckle <jstucklex@attglobal.net> - 2018-12-16 12:45 -0500
| From | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| Date | 2018-12-14 12:44 -0800 |
| Subject | Cannot retrieve error related to a specific file upload, in a 3-part input file blo |
| Message-ID | <4afe4c5b-25d8-4c61-ba76-1fb45b1d1203@googlegroups.com> |
Hi,
I’m having a problem retrieving errors about a specific file upload, in a range of 3 of them.
They are all single input file blocks, none of them multiple. It’s a SINGLE Submit to e.g. add_uploads.php .
The problem is that the $_FILES array is empty, whenever at least ONE of the file uploads has a problem.
So if 2 of the files are ok, but 1 of the files is too large for the maximum setting, then error relating to that specific file is unavailable.
Now, php_errormsg contains an appropriate error message. But it doesn’t indicate WHICH file upload was unsuccessful.
(How do you apply code formatting, for php or html fragments?)
<form action="./add_uploads.php" method="post" enctype="multipart/form-data">
/*
...
...
...
*/
<tr>
<td>
<label for="id-photo-id">Photo ID</label>
</td>
<td>
<input type="file" name="nme-photo-id" id="id-photo-id" accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" />
</td>
</tr>
<tr>
<td>
<label for="id-application">Application</label>
</td>
<td>
<input type="file" name="nme-application" id="id-application" accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" />
</td>
</tr>
<tr>
<td>
<label for="id-photo">Photo</label>
</td>
<td>
<input type="file" name="nme-photo" id="id-photo" accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" />
</td>
</tr>
[toc] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2018-12-14 22:02 +0100 |
| Message-ID | <5c141a5a$0$22349$e4fe514c@news.xs4all.nl> |
| In reply to | #17832 |
On 14-12-2018 21:44, Dan Campbell wrote: > Hi, > > I’m having a problem retrieving errors about a specific file upload, in a range of 3 of them. > > They are all single input file blocks, none of them multiple. It’s a SINGLE Submit to e.g. add_uploads.php . > > The problem is that the $_FILES array is empty, whenever at least ONE of the file uploads has a problem. > > > So if 2 of the files are ok, but 1 of the files is too large for the maximum setting, then error relating to that specific file is unavailable. > > Now, php_errormsg contains an appropriate error message. But it doesn’t indicate WHICH file upload was unsuccessful. > > > (How do you apply code formatting, for php or html fragments?) > > > <form action="./add_uploads.php" method="post" enctype="multipart/form-data"> > > This is comp.lang.php, so people reading here are far more interested in the PHP that's in 'add_uploads.php', than the HTML-code i wiped... ;)
[toc] | [prev] | [next] | [standalone]
| From | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| Date | 2018-12-14 13:45 -0800 |
| Message-ID | <89fa34e7-c2fd-4853-8b45-4ecd194fc905@googlegroups.com> |
| In reply to | #17833 |
On Friday, December 14, 2018 at 4:02:23 PM UTC-5, Luuk wrote:
> On 14-12-2018 21:44, Dan Campbell wrote:
> > Hi,
> >
> > I’m having a problem retrieving errors about a specific file upload, in a range of 3 of them.
> >
> > They are all single input file blocks, none of them multiple. It’s a SINGLE Submit to e.g. add_uploads.php .
> >
> > The problem is that the $_FILES array is empty, whenever at least ONE of the file uploads has a problem.
> >
> >
> > So if 2 of the files are ok, but 1 of the files is too large for the maximum setting, then error relating to that specific file is unavailable.
> >
> > Now, php_errormsg contains an appropriate error message. But it doesn’t indicate WHICH file upload was unsuccessful.
> >
> >
> > (How do you apply code formatting, for php or html fragments?)
> >
> >
> > <form action="./add_uploads.php" method="post" enctype="multipart/form-data">
> >
> >
>
> This is comp.lang.php, so people reading here are far more interested in
> the PHP that's in 'add_uploads.php', than the HTML-code i wiped... ;)
When we step througo to the very top of that file, on the very first code line $s_Error = $php_errormsg, the $_FILES array is empty, if there's an error in any of the uploads.
So the rest doesn't really matter.
<?php
$s_Error = $php_errormsg ;
$s_TemporaryDirectory = sys_get_temp_dir() ;
include 'login_inc.php' ;
include 'CheckImages.php' ;
include 'udfs.php' ;
$s_DocumentRoot = $_SERVER['DOCUMENT_ROOT'] ;
set_error_handler( "handleError" );
...
...
...
[toc] | [prev] | [next] | [standalone]
| From | Lew Pitcher <lew.pitcher@digitalfreehold.ca> |
|---|---|
| Date | 2018-12-14 17:07 -0500 |
| Message-ID | <pv19jq$3rg$1@dont-email.me> |
| In reply to | #17835 |
Dan Campbell wrote: > On Friday, December 14, 2018 at 4:02:23 PM UTC-5, Luuk wrote: >> On 14-12-2018 21:44, Dan Campbell wrote: >> > Hi, >> > >> > I’m having a problem retrieving errors about a specific file upload, in >> > a range of 3 of them. >> > >> > They are all single input file blocks, none of them multiple. It’s a >> > SINGLE Submit to e.g. add_uploads.php . >> > >> > The problem is that the $_FILES array is empty, whenever at least ONE >> > of the file uploads has a problem. >> > >> > >> > So if 2 of the files are ok, but 1 of the files is too large for the >> > maximum setting, then error relating to that specific file is >> > unavailable. >> > >> > Now, php_errormsg contains an appropriate error message. But it doesn’t >> > indicate WHICH file upload was unsuccessful. >> > >> > >> > (How do you apply code formatting, for php or html fragments?) >> > >> > >> > <form action="./add_uploads.php" method="post" >> > enctype="multipart/form-data"> >> > >> > HTML fragment restored: > <form action="./add_uploads.php" method="post" > enctype="multipart/form-data"> > > > /* > ... > ... > ... > > */ > > > <tr> > <td> > <label for="id-photo-id">Photo ID</label> > </td> > <td> > <input type="file" name="nme-photo-id" id="id-photo-id" > accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" /> > </td> > </tr> > <tr> > <td> > <label for="id-application">Application</label> > </td> > <td> > <input type="file" name="nme-application" id="id-application" > accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" /> > </td> > </tr> > > <tr> > <td> > <label for="id-photo">Photo</label> > </td> > <td> > <input type="file" name="nme-photo" id="id-photo" accept=".jpg, > .png, .jpeg, .gif, .bmp, .pdf" /> > </td> > </tr> >> >> This is comp.lang.php, so people reading here are far more interested in >> the PHP that's in 'add_uploads.php', than the HTML-code i wiped... ;) > > When we step througo to the very top of that file, on the very first code > line $s_Error = $php_errormsg, the $_FILES array is empty, if there's an > error in any of the uploads. > > So the rest doesn't really matter. > > > <?php > > > > $s_Error = $php_errormsg ; > > $s_TemporaryDirectory = sys_get_temp_dir() ; > > include 'login_inc.php' ; > include 'CheckImages.php' ; > include 'udfs.php' ; > > $s_DocumentRoot = $_SERVER['DOCUMENT_ROOT'] ; > > set_error_handler( "handleError" ); > ... > ... > ... Have you tried examining the $_FILES global variable? According to the PHP documentation at http://php.net/manual/en/features.file-upload.post-method.php your form handler should be able to examine $_FILES['nme-photo-id']['error'] for upload errors on nme-photo-id, $_FILES['nme-application']['error'] for upload errors on nme-application, and $_FILES['nme-photo']['error'] for upload errors on nme-photo HTH -- Lew Pitcher "In Skills, We Trust"
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2018-12-15 11:15 +0100 |
| Message-ID | <5c14d447$0$22354$e4fe514c@news.xs4all.nl> |
| In reply to | #17835 |
On 14-12-2018 22:45, Dan Campbell wrote: > On Friday, December 14, 2018 at 4:02:23 PM UTC-5, Luuk wrote: >> On 14-12-2018 21:44, Dan Campbell wrote: >>> Hi, >>> >>> I’m having a problem retrieving errors about a specific file upload, in a range of 3 of them. >>> >>> They are all single input file blocks, none of them multiple. It’s a SINGLE Submit to e.g. add_uploads.php . >>> >>> The problem is that the $_FILES array is empty, whenever at least ONE of the file uploads has a problem. >>> >>> >>> So if 2 of the files are ok, but 1 of the files is too large for the maximum setting, then error relating to that specific file is unavailable. >>> >>> Now, php_errormsg contains an appropriate error message. But it doesn’t indicate WHICH file upload was unsuccessful. >>> >>> >>> (How do you apply code formatting, for php or html fragments?) >>> >>> >>> <form action="./add_uploads.php" method="post" enctype="multipart/form-data"> >>> >>> >> >> This is comp.lang.php, so people reading here are far more interested in >> the PHP that's in 'add_uploads.php', than the HTML-code i wiped... ;) > > When we step througo to the very top of that file, on the very first code line $s_Error = $php_errormsg, the $_FILES array is empty, if there's an error in any of the uploads. > > So the rest doesn't really matter. > > > <?php > > > > $s_Error = $php_errormsg ; > > $s_TemporaryDirectory = sys_get_temp_dir() ; > > include 'login_inc.php' ; > include 'CheckImages.php' ; > include 'udfs.php' ; > > $s_DocumentRoot = $_SERVER['DOCUMENT_ROOT'] ; > > set_error_handler( "handleError" ); > .... > .... > .... > Check the settings of 'file_uploads' in your php.ini If file uploads is disabled, $_FILES remains empty.
[toc] | [prev] | [next] | [standalone]
| From | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| Date | 2018-12-15 05:50 -0800 |
| Message-ID | <1c2f78d9-eb17-4b50-ba74-fdd2f51b333e@googlegroups.com> |
| In reply to | #17837 |
On Saturday, December 15, 2018 at 5:15:41 AM UTC-5, Luuk wrote: > On 14-12-2018 22:45, Dan Campbell wrote: > > On Friday, December 14, 2018 at 4:02:23 PM UTC-5, Luuk wrote: > >> On 14-12-2018 21:44, Dan Campbell wrote: > >>> Hi, > >>> > >>> I’m having a problem retrieving errors about a specific file upload, in a range of 3 of them. > >>> > >>> They are all single input file blocks, none of them multiple. It’s a SINGLE Submit to e.g. add_uploads.php . > >>> > >>> The problem is that the $_FILES array is empty, whenever at least ONE of the file uploads has a problem. > >>> > >>> > >>> So if 2 of the files are ok, but 1 of the files is too large for the maximum setting, then error relating to that specific file is unavailable. > >>> > >>> Now, php_errormsg contains an appropriate error message. But it doesn’t indicate WHICH file upload was unsuccessful. > >>> > >>> > >>> (How do you apply code formatting, for php or html fragments?) > >>> > >>> > >>> <form action="./add_uploads.php" method="post" enctype="multipart/form-data"> > >>> > >>> > >> > >> This is comp.lang.php, so people reading here are far more interested in > >> the PHP that's in 'add_uploads.php', than the HTML-code i wiped... ;) > > > > When we step througo to the very top of that file, on the very first code line $s_Error = $php_errormsg, the $_FILES array is empty, if there's an error in any of the uploads. > > > > So the rest doesn't really matter. > > > > > > <?php > > > > > > > > $s_Error = $php_errormsg ; > > > > $s_TemporaryDirectory = sys_get_temp_dir() ; > > > > include 'login_inc.php' ; > > include 'CheckImages.php' ; > > include 'udfs.php' ; > > > > $s_DocumentRoot = $_SERVER['DOCUMENT_ROOT'] ; > > > > set_error_handler( "handleError" ); > > .... > > .... > > .... > > > > > Check the settings of 'file_uploads' in your php.ini > > If file uploads is disabled, $_FILES remains empty. Luuke and Lew, Thanks, but the code is able to upload files from all 3 inputs, and when all 3 uploads are legit, then the $_FILES array is populated as expected. The problem is that when there is at least one upload problem, the entire $_FILES array doesn't get populated. Anyway, it was suggested on another forum that this I'll have to use Javascript for this particular problem. If any other issues related to php and this thread, I'll post them here, thanks for the assist.
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2018-12-15 16:03 +0100 |
| Message-ID | <5c1517b9$0$22354$e4fe514c@news.xs4all.nl> |
| In reply to | #17838 |
On 15-12-2018 14:50, Dan Campbell wrote: > On Saturday, December 15, 2018 at 5:15:41 AM UTC-5, Luuk wrote: >> On 14-12-2018 22:45, Dan Campbell wrote: >>> On Friday, December 14, 2018 at 4:02:23 PM UTC-5, Luuk wrote: >>>> On 14-12-2018 21:44, Dan Campbell wrote: >>>>> Hi, >>>>> >>>>> I’m having a problem retrieving errors about a specific file upload, in a range of 3 of them. >>>>> >>>>> They are all single input file blocks, none of them multiple. It’s a SINGLE Submit to e.g. add_uploads.php . >>>>> >>>>> The problem is that the $_FILES array is empty, whenever at least ONE of the file uploads has a problem. >>>>> >>>>> >>>>> So if 2 of the files are ok, but 1 of the files is too large for the maximum setting, then error relating to that specific file is unavailable. >>>>> >>>>> Now, php_errormsg contains an appropriate error message. But it doesn’t indicate WHICH file upload was unsuccessful. >>>>> >>>>> >>>>> (How do you apply code formatting, for php or html fragments?) >>>>> >>>>> >>>>> <form action="./add_uploads.php" method="post" enctype="multipart/form-data"> >>>>> >>>>> >>>> >>>> This is comp.lang.php, so people reading here are far more interested in >>>> the PHP that's in 'add_uploads.php', than the HTML-code i wiped... ;) >>> >>> When we step througo to the very top of that file, on the very first code line $s_Error = $php_errormsg, the $_FILES array is empty, if there's an error in any of the uploads. >>> >>> So the rest doesn't really matter. >>> >>> >>> <?php >>> >>> >>> >>> $s_Error = $php_errormsg ; >>> >>> $s_TemporaryDirectory = sys_get_temp_dir() ; >>> >>> include 'login_inc.php' ; >>> include 'CheckImages.php' ; >>> include 'udfs.php' ; >>> >>> $s_DocumentRoot = $_SERVER['DOCUMENT_ROOT'] ; >>> >>> set_error_handler( "handleError" ); >>> .... >>> .... >>> .... >>> >> >> >> Check the settings of 'file_uploads' in your php.ini >> >> If file uploads is disabled, $_FILES remains empty. > > Luuke and Lew, > > Thanks, but the code is able to upload files from all 3 inputs, and when all 3 uploads are legit, then the $_FILES array is populated as expected. > > The problem is that when there is at least one upload problem, the entire $_FILES array doesn't get populated. > > Anyway, it was suggested on another forum that this I'll have to use Javascript for this particular problem. > > If any other issues related to php and this thread, I'll post them here, thanks for the assist. > BTW, i did read this 2 minutes ago: http://php.net/manual/en/features.file-upload.post-method.php posted by Mark, 8 years ago: $_FILES will be empty if a user attempts to upload a file greater than post_max_size in your php.ini post_max_size should be >= upload_max_filesize in your php.ini.
[toc] | [prev] | [next] | [standalone]
| From | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| Date | 2018-12-15 09:42 -0800 |
| Message-ID | <0615cec1-f8ac-4538-99f3-309e54dc1c15@googlegroups.com> |
| In reply to | #17839 |
On Saturday, December 15, 2018 at 10:03:27 AM UTC-5, Luuk wrote: > On 15-12-2018 14:50, Dan Campbell wrote: > > On Saturday, December 15, 2018 at 5:15:41 AM UTC-5, Luuk wrote: > >> On 14-12-2018 22:45, Dan Campbell wrote: > >>> On Friday, December 14, 2018 at 4:02:23 PM UTC-5, Luuk wrote: > >>>> On 14-12-2018 21:44, Dan Campbell wrote: > >>>>> Hi, > >>>>> > >>>>> I’m having a problem retrieving errors about a specific file upload, in a range of 3 of them. > >>>>> > >>>>> They are all single input file blocks, none of them multiple. It’s a SINGLE Submit to e.g. add_uploads.php . > >>>>> > >>>>> The problem is that the $_FILES array is empty, whenever at least ONE of the file uploads has a problem. > >>>>> > >>>>> > >>>>> So if 2 of the files are ok, but 1 of the files is too large for the maximum setting, then error relating to that specific file is unavailable. > >>>>> > >>>>> Now, php_errormsg contains an appropriate error message. But it doesn’t indicate WHICH file upload was unsuccessful. > >>>>> > >>>>> > >>>>> (How do you apply code formatting, for php or html fragments?) > >>>>> > >>>>> > >>>>> <form action="./add_uploads.php" method="post" enctype="multipart/form-data"> > >>>>> > >>>>> > >>>> > >>>> This is comp.lang.php, so people reading here are far more interested in > >>>> the PHP that's in 'add_uploads.php', than the HTML-code i wiped... ;) > >>> > >>> When we step througo to the very top of that file, on the very first code line $s_Error = $php_errormsg, the $_FILES array is empty, if there's an error in any of the uploads. > >>> > >>> So the rest doesn't really matter. > >>> > >>> > >>> <?php > >>> > >>> > >>> > >>> $s_Error = $php_errormsg ; > >>> > >>> $s_TemporaryDirectory = sys_get_temp_dir() ; > >>> > >>> include 'login_inc.php' ; > >>> include 'CheckImages.php' ; > >>> include 'udfs.php' ; > >>> > >>> $s_DocumentRoot = $_SERVER['DOCUMENT_ROOT'] ; > >>> > >>> set_error_handler( "handleError" ); > >>> .... > >>> .... > >>> .... > >>> > >> > >> > >> Check the settings of 'file_uploads' in your php.ini > >> > >> If file uploads is disabled, $_FILES remains empty. > > > > Luuke and Lew, > > > > Thanks, but the code is able to upload files from all 3 inputs, and when all 3 uploads are legit, then the $_FILES array is populated as expected. > > > > The problem is that when there is at least one upload problem, the entire $_FILES array doesn't get populated. > > > > Anyway, it was suggested on another forum that this I'll have to use Javascript for this particular problem. > > > > If any other issues related to php and this thread, I'll post them here, thanks for the assist. > > > > BTW, i did read this 2 minutes ago: > http://php.net/manual/en/features.file-upload.post-method.php > posted by Mark, 8 years ago: > $_FILES will be empty if a user attempts to upload a file greater than > post_max_size in your php.ini > > post_max_size should be >= upload_max_filesize in your php.ini. Yes, that correct Luuk. And we can't count on customers respecting our file size max, so we need to trap the error when customers try to upload a file that's too large. Because $_FILES is empty in that case, it apparently can't be trapped within php, and therefore we have to do it on the client. Regards, DC
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2018-12-15 20:01 +0100 |
| Message-ID | <5c154fa2$0$22363$e4fe514c@news.xs4all.nl> |
| In reply to | #17840 |
On 15-12-2018 18:42, Dan Campbell wrote: > On Saturday, December 15, 2018 at 10:03:27 AM UTC-5, Luuk wrote: >> On 15-12-2018 14:50, Dan Campbell wrote: >>> On Saturday, December 15, 2018 at 5:15:41 AM UTC-5, Luuk wrote: >>>> On 14-12-2018 22:45, Dan Campbell wrote: >>>>> On Friday, December 14, 2018 at 4:02:23 PM UTC-5, Luuk wrote: >>>>>> On 14-12-2018 21:44, Dan Campbell wrote: >>>>>>> Hi, >>>>>>> >>>>>>> I’m having a problem retrieving errors about a specific file upload, in a range of 3 of them. >>>>>>> >>>>>>> They are all single input file blocks, none of them multiple. It’s a SINGLE Submit to e.g. add_uploads.php . >>>>>>> >>>>>>> The problem is that the $_FILES array is empty, whenever at least ONE of the file uploads has a problem. >>>>>>> >>>>>>> >>>>>>> So if 2 of the files are ok, but 1 of the files is too large for the maximum setting, then error relating to that specific file is unavailable.. >>>>>>> >>>>>>> Now, php_errormsg contains an appropriate error message. But it doesn’t indicate WHICH file upload was unsuccessful. >>>>>>> >>>>>>> >>>>>>> (How do you apply code formatting, for php or html fragments?) >>>>>>> >>>>>>> >>>>>>> <form action="./add_uploads.php" method="post" enctype="multipart/form-data"> >>>>>>> >>>>>>> >>>>>> >>>>>> This is comp.lang.php, so people reading here are far more interested in >>>>>> the PHP that's in 'add_uploads.php', than the HTML-code i wiped... ;) >>>>> >>>>> When we step througo to the very top of that file, on the very first code line $s_Error = $php_errormsg, the $_FILES array is empty, if there's an error in any of the uploads. >>>>> >>>>> So the rest doesn't really matter. >>>>> >>>>> >>>>> <?php >>>>> >>>>> >>>>> >>>>> $s_Error = $php_errormsg ; >>>>> >>>>> $s_TemporaryDirectory = sys_get_temp_dir() ; >>>>> >>>>> include 'login_inc.php' ; >>>>> include 'CheckImages.php' ; >>>>> include 'udfs.php' ; >>>>> >>>>> $s_DocumentRoot = $_SERVER['DOCUMENT_ROOT'] ; >>>>> >>>>> set_error_handler( "handleError" ); >>>>> .... >>>>> .... >>>>> .... >>>>> >>>> >>>> >>>> Check the settings of 'file_uploads' in your php.ini >>>> >>>> If file uploads is disabled, $_FILES remains empty. >>> >>> Luuke and Lew, >>> >>> Thanks, but the code is able to upload files from all 3 inputs, and when all 3 uploads are legit, then the $_FILES array is populated as expected. >>> >>> The problem is that when there is at least one upload problem, the entire $_FILES array doesn't get populated. >>> >>> Anyway, it was suggested on another forum that this I'll have to use Javascript for this particular problem. >>> >>> If any other issues related to php and this thread, I'll post them here, thanks for the assist. >>> >> >> BTW, i did read this 2 minutes ago: >> http://php.net/manual/en/features.file-upload.post-method.php >> posted by Mark, 8 years ago: >> $_FILES will be empty if a user attempts to upload a file greater than >> post_max_size in your php.ini >> >> post_max_size should be >= upload_max_filesize in your php.ini. > > Yes, that correct Luuk. And we can't count on customers respecting our file size max, so we need to trap the error when customers try to upload a file that's too large. > > Because $_FILES is empty in that case, it apparently can't be trapped within php, and therefore we have to do it on the client. > > > Regards, > > DC > You als ocould stop the error ath Apache bij adding 'LimitRequestBody' to your config (see: http://httpd.apache.org/docs/2.0/mod/core.html#limitrequestbody ) In that case, when upload is too large a HTTP 413 is thrown, which should be handled client side.
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2018-12-16 02:11 +0100 |
| Message-ID | <g7ln19Fagd9U1@mid.individual.net> |
| In reply to | #17839 |
Luuk:
[...]
> BTW, i did read this 2 minutes ago:
> http://php.net/manual/en/features.file-upload.post-method.php
> posted by Mark, 8 years ago:
> $_FILES will be empty if a user attempts to upload a file greater than
> post_max_size in your php.ini
>
> post_max_size should be >= upload_max_filesize in your php.ini.
If you read the text at the mentioned URL, you will also find a note
about how to tell the browser the size limit, so people don't try to
upload stuff, which is too large:
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="__URL__" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
The __URL__ in the above example should be replaced, and point to a PHP
file.
The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file
input field, and its value is the maximum filesize accepted by PHP. This
form element should always be used as it saves users the trouble of
waiting for a big file being transferred only to find that it was too
large and the transfer failed.
(quote end)
And this may help as well:
<https://stackoverflow.com/questions/2934788/detecting-file-upload-size-on-the-client-side>
<https://stackoverflow.com/questions/6327965/html-upload-max-file-size-does-not-appear-to-work>
--
Arno Welzel
https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2018-12-16 14:22 +0100 |
| Message-ID | <5c1651a4$0$22338$e4fe514c@news.xs4all.nl> |
| In reply to | #17842 |
On 16-12-2018 02:11, Arno Welzel wrote: > Luuk: > > [...] >> BTW, i did read this 2 minutes ago: >> http://php.net/manual/en/features.file-upload.post-method.php >> posted by Mark, 8 years ago: >> $_FILES will be empty if a user attempts to upload a file greater than >> post_max_size in your php.ini >> >> post_max_size should be >= upload_max_filesize in your php.ini. > > If you read the text at the mentioned URL, you will also find a note > about how to tell the browser the size limit, so people don't try to > upload stuff, which is too large: > > <!-- The data encoding type, enctype, MUST be specified as below --> > <form enctype="multipart/form-data" action="__URL__" method="POST"> > <!-- MAX_FILE_SIZE must precede the file input field --> > <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> > <!-- Name of input element determines name in $_FILES array --> > Send this file: <input name="userfile" type="file" /> > <input type="submit" value="Send File" /> > </form> > > The __URL__ in the above example should be replaced, and point to a PHP > file. > > The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file > input field, and its value is the maximum filesize accepted by PHP. This > form element should always be used as it saves users the trouble of > waiting for a big file being transferred only to find that it was too > large and the transfer failed. > > (quote end) > > And this may help as well: > > <https://stackoverflow.com/questions/2934788/detecting-file-upload-size-on-the-client-side> > > <https://stackoverflow.com/questions/6327965/html-upload-max-file-size-does-not-appear-to-work> > > This will be difficult to implement, because OP is trying to upload 3 files. Javascript seems to be needed to do this job.
[toc] | [prev] | [next] | [standalone]
| From | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| Date | 2018-12-16 11:05 -0800 |
| Message-ID | <c37a5fb4-1791-421e-becc-de96f15dd76c@googlegroups.com> |
| In reply to | #17843 |
On Sunday, December 16, 2018 at 8:22:49 AM UTC-5, Luuk wrote: > On 16-12-2018 02:11, Arno Welzel wrote: > > Luuk: > > > > [...] > >> BTW, i did read this 2 minutes ago: > >> http://php.net/manual/en/features.file-upload.post-method.php > >> posted by Mark, 8 years ago: > >> $_FILES will be empty if a user attempts to upload a file greater than > >> post_max_size in your php.ini > >> > >> post_max_size should be >= upload_max_filesize in your php.ini. > > > > If you read the text at the mentioned URL, you will also find a note > > about how to tell the browser the size limit, so people don't try to > > upload stuff, which is too large: > > > > <!-- The data encoding type, enctype, MUST be specified as below --> > > <form enctype="multipart/form-data" action="__URL__" method="POST"> > > <!-- MAX_FILE_SIZE must precede the file input field --> > > <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> > > <!-- Name of input element determines name in $_FILES array --> > > Send this file: <input name="userfile" type="file" /> > > <input type="submit" value="Send File" /> > > </form> > > > > The __URL__ in the above example should be replaced, and point to a PHP > > file. > > > > The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file > > input field, and its value is the maximum filesize accepted by PHP. This > > form element should always be used as it saves users the trouble of > > waiting for a big file being transferred only to find that it was too > > large and the transfer failed. > > > > (quote end) > > > > And this may help as well: > > > > <https://stackoverflow.com/questions/2934788/detecting-file-upload-size-on-the-client-side> > > > > <https://stackoverflow.com/questions/6327965/html-upload-max-file-size-does-not-appear-to-work> > > > > > > This will be difficult to implement, because OP is trying to upload 3 files. > Javascript seems to be needed to do this job. Yes, ultimately we'll use a JS script, for whenever there is any kind of error in one or more uploads. But Arno's suggestion will at least resolve the File Size issue, and help the client to avoid wasting time. Regards, DC
[toc] | [prev] | [next] | [standalone]
| From | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| Date | 2018-12-16 11:02 -0800 |
| Message-ID | <8384c3dc-6905-4c82-90b3-7225c1526b4f@googlegroups.com> |
| In reply to | #17842 |
On Saturday, December 15, 2018 at 8:11:12 PM UTC-5, Arno Welzel wrote: > Luuk: > > [...] > > BTW, i did read this 2 minutes ago: > > http://php.net/manual/en/features.file-upload.post-method.php > > posted by Mark, 8 years ago: > > $_FILES will be empty if a user attempts to upload a file greater than > > post_max_size in your php.ini > > > > post_max_size should be >= upload_max_filesize in your php.ini. > > If you read the text at the mentioned URL, you will also find a note > about how to tell the browser the size limit, so people don't try to > upload stuff, which is too large: > > <!-- The data encoding type, enctype, MUST be specified as below --> > <form enctype="multipart/form-data" action="__URL__" method="POST"> > <!-- MAX_FILE_SIZE must precede the file input field --> > <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> > <!-- Name of input element determines name in $_FILES array --> > Send this file: <input name="userfile" type="file" /> > <input type="submit" value="Send File" /> > </form> > > The __URL__ in the above example should be replaced, and point to a PHP > file. > > The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file > input field, and its value is the maximum filesize accepted by PHP. This > form element should always be used as it saves users the trouble of > waiting for a big file being transferred only to find that it was too > large and the transfer failed. > > (quote end) > > And this may help as well: > > <https://stackoverflow.com/questions/2934788/detecting-file-upload-size-on-the-client-side> > > <https://stackoverflow.com/questions/6327965/html-upload-max-file-size-does-not-appear-to-work> > > > -- > Arno Welzel > https://arnowelzel.de Arno, I think this might work. We'll probably implement a Javascript solution as well, but in the meantime the client will be prevented from even trying. Looks good, we'll try this during the week, thanks. Regards, DC
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2018-12-16 23:30 +0100 |
| Message-ID | <pv6jmb$fv2$1@solani.org> |
| In reply to | #17842 |
On 16.12.2018 at 02:11, Arno Welzel wrote: > If you read the text at the mentioned URL, you will also find a note > about how to tell the browser the size limit, so people don't try to > upload stuff, which is too large: It is not about telling the browser about any limit. > The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file > input field, and its value is the maximum filesize accepted by PHP. This > form element should always be used as it saves users the trouble of > waiting for a big file being transferred only to find that it was too > large and the transfer failed. MAX_FILE_SIZE is rather something that PHP will check, and abort the upload if exceeded, see <https://github.com/php/php-src/blob/php-7.3.0/main/rfc1867.c>. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| Date | 2018-12-16 15:15 -0800 |
| Message-ID | <34079e12-ebc5-4ff5-aed3-9081dc393bf5@googlegroups.com> |
| In reply to | #17847 |
On Sunday, December 16, 2018 at 5:30:40 PM UTC-5, Christoph M. Becker wrote: > On 16.12.2018 at 02:11, Arno Welzel wrote: > > > If you read the text at the mentioned URL, you will also find a note > > about how to tell the browser the size limit, so people don't try to > > upload stuff, which is too large: > > It is not about telling the browser about any limit. > > > The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file > > input field, and its value is the maximum filesize accepted by PHP. This > > form element should always be used as it saves users the trouble of > > waiting for a big file being transferred only to find that it was too > > large and the transfer failed. > > MAX_FILE_SIZE is rather something that PHP will check, and abort the > upload if exceeded, see > <https://github.com/php/php-src/blob/php-7.3.0/main/rfc1867.c>. > > -- > Christoph M. Becker Coupla things, Chris: We're using php 5.6. PHP is already aborting the upload, and reporting that a file size exceeded the max. The problem is, that the error doesn't specify which upload had the problem. So if you're uploading 3 files, it aborts all 3, and there's no way of telling which file caused the problem. So I'd rather throw that hidden field in, so the upload doesn't even attempt to take place, and we don't have to wait for the error to get triggered. Anyway, I need to test this out first thing.
[toc] | [prev] | [next] | [standalone]
| From | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| Date | 2018-12-17 07:01 -0800 |
| Message-ID | <3e6234ed-e98c-44a4-ad84-eaace5216ebd@googlegroups.com> |
| In reply to | #17842 |
On Saturday, December 15, 2018 at 8:11:12 PM UTC-5, Arno Welzel wrote: > Luuk: > > [...] > > BTW, i did read this 2 minutes ago: > > http://php.net/manual/en/features.file-upload.post-method.php > > posted by Mark, 8 years ago: > > $_FILES will be empty if a user attempts to upload a file greater than > > post_max_size in your php.ini > > > > post_max_size should be >= upload_max_filesize in your php.ini. > > If you read the text at the mentioned URL, you will also find a note > about how to tell the browser the size limit, so people don't try to > upload stuff, which is too large: > > <!-- The data encoding type, enctype, MUST be specified as below --> > <form enctype="multipart/form-data" action="__URL__" method="POST"> > <!-- MAX_FILE_SIZE must precede the file input field --> > <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> > <!-- Name of input element determines name in $_FILES array --> > Send this file: <input name="userfile" type="file" /> > <input type="submit" value="Send File" /> > </form> > > The __URL__ in the above example should be replaced, and point to a PHP > file. > > The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file > input field, and its value is the maximum filesize accepted by PHP. This > form element should always be used as it saves users the trouble of > waiting for a big file being transferred only to find that it was too > large and the transfer failed. > > (quote end) > > And this may help as well: > > <https://stackoverflow.com/questions/2934788/detecting-file-upload-size-on-the-client-side> > > <https://stackoverflow.com/questions/6327965/html-upload-max-file-size-does-not-appear-to-work> > > > -- > Arno Welzel > https://arnowelzel.de Arno, The HTML injection didn't work. I set it to a very low figure - a million bytes - while the php.ini was set to 4M. It didn't prevent the attempt to upload, and did the same thing it would without the hidden input field - set the $php_errormsg variable to "POST Content-Length of 4273824 bytes exceeds the limit of 4194304 bytes" , without specifying which file was too large, and then just didn't do the upload. Exactly the same as before. Anyway, I'll code the javascript today, and move on. Regards, DC
[toc] | [prev] | [next] | [standalone]
| From | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| Date | 2019-01-29 07:06 -0800 |
| Message-ID | <70fa3a0f-7fd7-4f62-b569-b3035059022e@googlegroups.com> |
| In reply to | #17849 |
On Monday, December 17, 2018 at 10:02:03 AM UTC-5, Dan Campbell wrote: > On Saturday, December 15, 2018 at 8:11:12 PM UTC-5, Arno Welzel wrote: > > Luuk: > > > > [...] > > > BTW, i did read this 2 minutes ago: > > > http://php.net/manual/en/features.file-upload.post-method.php > > > posted by Mark, 8 years ago: > > > $_FILES will be empty if a user attempts to upload a file greater than > > > post_max_size in your php.ini > > > > > > post_max_size should be >= upload_max_filesize in your php.ini. > > > > If you read the text at the mentioned URL, you will also find a note > > about how to tell the browser the size limit, so people don't try to > > upload stuff, which is too large: > > > > <!-- The data encoding type, enctype, MUST be specified as below --> > > <form enctype="multipart/form-data" action="__URL__" method="POST"> > > <!-- MAX_FILE_SIZE must precede the file input field --> > > <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> > > <!-- Name of input element determines name in $_FILES array --> > > Send this file: <input name="userfile" type="file" /> > > <input type="submit" value="Send File" /> > > </form> > > > > The __URL__ in the above example should be replaced, and point to a PHP > > file. > > > > The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file > > input field, and its value is the maximum filesize accepted by PHP. This > > form element should always be used as it saves users the trouble of > > waiting for a big file being transferred only to find that it was too > > large and the transfer failed. > > > > (quote end) > > > > And this may help as well: > > > > <https://stackoverflow.com/questions/2934788/detecting-file-upload-size-on-the-client-side> > > > > <https://stackoverflow.com/questions/6327965/html-upload-max-file-size-does-not-appear-to-work> > > > > > > -- > > Arno Welzel > > https://arnowelzel.de > > Arno, > > The HTML injection didn't work. I set it to a very low figure - a million bytes - while the php.ini was set to 4M. > > It didn't prevent the attempt to upload, and did the same thing it would without the hidden input field - set the $php_errormsg variable to > > "POST Content-Length of 4273824 bytes exceeds the limit of 4194304 bytes" > > > , without specifying which file was too large, and then just didn't do the upload. Exactly the same as before. > > > Anyway, I'll code the javascript today, and move on. > > > Regards, > > DC Forgot to update everyone about this. It turned out to be a max file size setting in IIS, rather than in PHP. It was set at something like 3 mg. Since I don't have access to IIS for this application, it was impossible for me to figure this out.
[toc] | [prev] | [next] | [standalone]
| From | bill <william@TechServSys.com> |
|---|---|
| Date | 2019-01-30 06:43 -0500 |
| Message-ID | <q2s2ko$1bta$1@gioia.aioe.org> |
| In reply to | #17869 |
On 1/29/2019 10:06 AM, Dan Campbell wrote: ... > > Forgot to update everyone about this. It turned out to be a max file size setting in IIS, rather than in PHP. It was set at something like 3 mg. > > Since I don't have access to IIS for this application, it was impossible for me to figure this out. > Thanks for the update. -bill
[toc] | [prev] | [next] | [standalone]
| From | Dan Campbell <dcwhatthe@gmail.com> |
|---|---|
| Date | 2018-12-14 13:42 -0800 |
| Message-ID | <805df8df-e605-4f44-b4c7-35814ce22e86@googlegroups.com> |
| In reply to | #17832 |
On Friday, December 14, 2018 at 3:44:49 PM UTC-5, Dan Campbell wrote: > Hi, > > I’m having a problem retrieving errors about a specific file upload, in a range of 3 of them. > > They are all single input file blocks, none of them multiple. It’s a SINGLE Submit to e.g. add_uploads.php . > > The problem is that the $_FILES array is empty, whenever at least ONE of the file uploads has a problem. > > > So if 2 of the files are ok, but 1 of the files is too large for the maximum setting, then error relating to that specific file is unavailable. > > Now, php_errormsg contains an appropriate error message. But it doesn’t indicate WHICH file upload was unsuccessful. > > > (How do you apply code formatting, for php or html fragments?) > > > <form action="./add_uploads.php" method="post" enctype="multipart/form-data"> > > > /* > ... > ... > ... > > */ > > > <tr> > <td> > <label for="id-photo-id">Photo ID</label> > </td> > <td> > <input type="file" name="nme-photo-id" id="id-photo-id" accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" /> > </td> > </tr> > <tr> > <td> > <label for="id-application">Application</label> > </td> > <td> > <input type="file" name="nme-application" id="id-application" accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" /> > </td> > </tr> > > <tr> > <td> > <label for="id-photo">Photo</label> > </td> > <td> > <input type="file" name="nme-photo" id="id-photo" accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" /> > </td> > </tr> I'm not able to send any more responses to this thread. There's an address not found error, and Your message wasn't delivered to comp.lang.php@googlegroups.com because the address couldn't be found, or is unable to receive mail.
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2018-12-16 12:45 -0500 |
| Message-ID | <pv62v9$gd8$1@jstuckle.eternal-september.org> |
| In reply to | #17834 |
On 12/14/2018 4:42 PM, Dan Campbell wrote: > On Friday, December 14, 2018 at 3:44:49 PM UTC-5, Dan Campbell wrote: >> Hi, >> >> I’m having a problem retrieving errors about a specific file upload, in a range of 3 of them. >> >> They are all single input file blocks, none of them multiple. It’s a SINGLE Submit to e.g. add_uploads.php . >> >> The problem is that the $_FILES array is empty, whenever at least ONE of the file uploads has a problem. >> >> >> So if 2 of the files are ok, but 1 of the files is too large for the maximum setting, then error relating to that specific file is unavailable. >> >> Now, php_errormsg contains an appropriate error message. But it doesn’t indicate WHICH file upload was unsuccessful. >> >> >> (How do you apply code formatting, for php or html fragments?) >> >> >> <form action="./add_uploads.php" method="post" enctype="multipart/form-data"> >> >> >> /* >> ... >> ... >> ... >> >> */ >> >> >> <tr> >> <td> >> <label for="id-photo-id">Photo ID</label> >> </td> >> <td> >> <input type="file" name="nme-photo-id" id="id-photo-id" accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" /> >> </td> >> </tr> >> <tr> >> <td> >> <label for="id-application">Application</label> >> </td> >> <td> >> <input type="file" name="nme-application" id="id-application" accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" /> >> </td> >> </tr> >> >> <tr> >> <td> >> <label for="id-photo">Photo</label> >> </td> >> <td> >> <input type="file" name="nme-photo" id="id-photo" accept=".jpg, .png, .jpeg, .gif, .bmp, .pdf" /> >> </td> >> </tr> > > I'm not able to send any more responses to this thread. There's an address not found error, and > > Your message wasn't delivered to comp.lang.php@googlegroups.com because the address couldn't be found, or is unable to receive mail. > The solution is simple. Use a real news reader - not Google Groups. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ==================
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web