Basic file upload doubt

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Basic file upload doubt

Post by dude81 »

Can't a I put a file upload in a normal POST form? I tried this I always get $_POST['file-form-variablename1'] but not anything in $_FILES
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Basic file upload doubt

Post by VladSun »

Code: Select all

<form enctype="multipart/form-data" .....
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Re: Basic file upload doubt

Post by dude81 »

The forms we use in our project would be typically look like the following

Code: Select all

 
<form  enctype="multipart/form-data"  action='index.php?x=manager&y=event'  name='event'  method="post" onSubmit="return checkForm();">
<input type="text" name="first_field_value" value=''>
<input type="text" name="second_field_value" value=''>
<input type="file" name="uploadedfile">
<input type="submit" name="submitButton" value="Submit">
 
x and y are parsed and then sent to a right action file
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Basic file upload doubt

Post by VladSun »

Check you php.ini for file upload permitions.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Re: Basic file upload doubt

Post by dude81 »

I doubted that, but What should I check there?

Code: Select all

 
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
 
; Whether to allow HTTP file uploads.
file_uploads = On
 
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = "\xampp\tmp"
 
; Maximum allowed size for uploaded files.
upload_max_filesize = 32M
 
 
;;;;;;;;;;;;;;;;;;
; Fopen wrappers ;
;;;;;;;;;;;;;;;;;;
 
; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On
 
; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
allow_url_include = Off
 
; Define the anonymous ftp password (your email address)
;from="john@doe.com"
 
; Define the User-Agent string
; user_agent="PHP"
 
; Default timeout for socket based streams (seconds)
default_socket_timeout = 60
 
; If your scripts have to deal with files from Macintosh systems,
; or you are running on a Mac and need to deal with files from
; unix or win32 systems, setting this flag will cause PHP to
; automatically detect the EOL character in those files so that
; fgets() and file() will work regardless of the source of the file.
; auto_detect_line_endings = Off
 
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Basic file upload doubt

Post by VladSun »

Would you mind posting the output of var_dump($_FILES) ?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Re: Basic file upload doubt

Post by dude81 »

its an empty array
Post Reply