Page 1 of 1

Uploading a file

Posted: Tue Jul 10, 2007 10:01 pm
by HiddenS3crets
I have a register form that allows a user to upload an icon.

My scripts look alright, but the problem is that the $_FILES variable is not storing any information about the file being uploaded; I think it may be because I'm not loading a complete new page. Instead my form sends user data to a javascript function which then sends a post request to a register script.

Code: Select all

<?php
// Not storing anything (register script)
$_FILES['icon']['tmp_name'];
?>
I'm not quite sure, but I think the problem is that I'm not loading a new page so there's no way to update the $_FILES['icon'][*] fields.

How can I get around while still keeping intact my current setup?

Posted: Wed Jul 11, 2007 1:54 am
by tapas_bahirbag
You must have to use
enctype="multipart/form-data"
this in the form tag of your register form.

--
Tapos Pal

Posted: Wed Jul 11, 2007 11:22 am
by HiddenS3crets
I do have that

Posted: Wed Jul 11, 2007 3:00 pm
by feyd
Post more code.

Posted: Sat Jul 14, 2007 10:45 pm
by HiddenS3crets
This is a simplified version of my code.

Code: Select all

<form enctype='multipart/form-data' action='javascript:register()' method='post'>

Code: Select all

<input type='hidden' name='MAX_FILE_SIZE'  value='100000' />
<input type='file' name='icon' />
The javascript function register() then sends post information to the signup script

I try to echo $_FILES['icon']['name'], but there is no value there. To go broader, $_FILES is empty.

Why isn't the information being inserted into the $_FILES array?

Update: I noticed that if I post directly to the signup script and skip the javascript information is inserted into $_FILES, which is good, but the format of the site needs the javascript middleman. Is there a way that this information can be sent so I can keep my javascript intact?

Posted: Sat Jul 14, 2007 11:02 pm
by feyd
Why is your action Javascript?