consultgal
asked on
$_FILES not working after move to dedicated server
My site was hosted on a shared server. I am in the midst of trying to switch to a dedicated server after performace issues. However, code that had been working on the old server is no longer working on the new. It is a linux box, which i don't know very much about, so i'm trying to learn. Specifically, code that was working to upload files is no longer working. Here is the code:
<table width="77%" border="0" cellspacing="0" cellpadding="3" align="center">
<form action="?page=2" method="post" enctype="multipart/form-da ta">
<tr>
<td colspan="2"><div align="center"><strong><fo nt size="+2" face="Verdana, Arial, Helvetica, sans-serif">Upload
CSV File</font></strong></div> </td>
</tr>
<tr>
<td width="22%">File</td>
<td width="78%"><input type="hidden" name="MAX_FILE_SIZE" value="20000">
<input type="file" name="csvfile"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value=" Submit "></td>
</tr>
</form>
</table>
However, after submitting the form, the $_FILES array is empty.
I think maybe it has to do with permissions on the temp directory. The temp directory is not set in php.ini, so it is my understanding that it is using the default temp directory for the server.
<table width="77%" border="0" cellspacing="0" cellpadding="3" align="center">
<form action="?page=2" method="post" enctype="multipart/form-da
<tr>
<td colspan="2"><div align="center"><strong><fo
CSV File</font></strong></div>
</tr>
<tr>
<td width="22%">File</td>
<td width="78%"><input type="hidden" name="MAX_FILE_SIZE" value="20000">
<input type="file" name="csvfile"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value=" Submit "></td>
</tr>
</form>
</table>
However, after submitting the form, the $_FILES array is empty.
I think maybe it has to do with permissions on the temp directory. The temp directory is not set in php.ini, so it is my understanding that it is using the default temp directory for the server.
"The temp directory is not set in php.ini" : Have you set it? Because that is more than likely the problem
According to what i’ve read on the manual, it seems to be caused by having
file_uploads = off
in the php.ini, or (as it was in my case), having no free space available.
file_uploads = off
in the php.ini, or (as it was in my case), having no free space available.
Don’t forget to always have the form tag include the enctype=”multipart/form-da ta”
If you don’t put this in, you won’t see anything in your _FILES var.
Uhhhgh! I’m an idiot! Aside from needing to have enctype=multipart/form-dat a, I found that i had made my MAXFILESIZE hidden tag set too low, PHP parses this and will spit out 2 as the value for the error element in the files hash.
If you don’t put this in, you won’t see anything in your _FILES var.
Uhhhgh! I’m an idiot! Aside from needing to have enctype=multipart/form-dat
http://getluky.net/2004/10/04/apachephp-_files-array-mysteriously-empty/
check
1) Whether file upload is enabled in your php.ini.
2) Check whether the temporary upload folder is set correctly in
php.ini file.
3) The html tag form sometime must have the attribute
'enctype="multipart/form-d ata"' set.
http://www.faqts.com/knowledge_base/view.phtml/aid/19252
Hopefully these help.
check
1) Whether file upload is enabled in your php.ini.
2) Check whether the temporary upload folder is set correctly in
php.ini file.
3) The html tag form sometime must have the attribute
'enctype="multipart/form-d
http://www.faqts.com/knowledge_base/view.phtml/aid/19252
Hopefully these help.
ASKER
1. File upload ins enabled in php.ini
2. This is what I think the problem is. Can someone please tell me the correct way to set this? After leaving it empty, thinking that it would just use the default for the server which should have the appropriate permissions, I currently have it set to "./tmp/". However, since I know nothing about linux, I don't know where that driectory actually resides so that I can check for the appropriate permissions.
3. As you can see in my code snippet above, I do have that.
2. This is what I think the problem is. Can someone please tell me the correct way to set this? After leaving it empty, thinking that it would just use the default for the server which should have the appropriate permissions, I currently have it set to "./tmp/". However, since I know nothing about linux, I don't know where that driectory actually resides so that I can check for the appropriate permissions.
3. As you can see in my code snippet above, I do have that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the points, I would also like to know what fixed it?
Steven
Steven
ASKER
Oops, I thought I posted a response....weird.
Anyway, what I thought I said was: my dedicated server was running version 3.x of MySQL, which not only explains the above problem but another one I was having with a query using UNION. Doh! Now, being a Linux newbie I just need to figure out how to install a GPG key so I can upgrade.
Thanks!
Courtney
Anyway, what I thought I said was: my dedicated server was running version 3.x of MySQL, which not only explains the above problem but another one I was having with a query using UNION. Doh! Now, being a Linux newbie I just need to figure out how to install a GPG key so I can upgrade.
Thanks!
Courtney