Problem with custom module and file upload

Author Message

Sébastien Antoniotti

Saturday 17 May 2008 8:34:34 am

Hi !

I'm writing a custom module who permit to upload a file.

Here is the basic form I'm using :

	<form enctype="multipart/form-data" method="post" action={"mymodule/send"|ezurl}>
		<input name="file1" type="file" size="20" />
		<input name="text1" type="text" value="lorem"/>                        
		<input type="submit" name="SendButton" value="send" />
	</form>

Here is the executed code behind the send view of my module :

echo "<pre>";print_r($_POST);echo "</pre>";

and the output after submitting the form is :

Array
(
    [text1] => lorem
    [SendButton] => send
)

I don't understand why the file1 attribute is not present in $_POST !

I precise that files uploads into the administration interface are OK, so I don't think that the problem is global to my server.

Please help me before I become crazy, I spent one hour to find a solution =(

Thanks in advance for your help !

eZ Publish Freelance
web : http://www.webaxis.fr

Bartek Modzelewski

Saturday 17 May 2008 9:34:45 am

Hi Sébastien,

sometimes developers forget about some obvious basic things ;-) Uploaded file data are in global $_FILES, not in $_POST.

http://pl2.php.net/features.file-upload

Cheers
Bartek

Baobaz
http://www.baobaz.com

Sébastien Antoniotti

Saturday 17 May 2008 12:13:54 pm

Hi Bartek,

Of course, it's so basic and I forgot it !

Many thanks because I was really nervous not succeed in making this thing so simple !!

Cheers,
Seb.

eZ Publish Freelance
web : http://www.webaxis.fr

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:14:01
Script start
Timing: Jan 18 2025 19:14:01
Module start 'layout'
Timing: Jan 18 2025 19:14:01
Module start 'content'
Timing: Jan 18 2025 19:14:01
Module end 'content'
Timing: Jan 18 2025 19:14:01
Script end

Main resources:

Total runtime0.0217 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 589.1797152.6406
Module start 'layout' 0.00710.0038 741.820339.4766
Module start 'content' 0.01090.0075 781.296989.4922
Module end 'content' 0.01840.0033 870.789134.3047
Script end 0.0217  905.0938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003415.7921140.0002
Check MTime0.00177.8972140.0001
Mysql Total
Database connection0.00104.696610.0010
Mysqli_queries0.003616.409630.0012
Looping result0.00000.115210.0000
Template Total0.002410.910.0024
Template load0.00104.489310.0010
Template processing0.00146.417510.0014
Override
Cache load0.00073.013010.0007
General
dbfile0.00209.076380.0002
String conversion0.00000.049440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs