Link to home
Start Free TrialLog in
Avatar of consultgal
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-data">
  <tr>
    <td colspan="2"><div align="center"><strong><font 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>&nbsp;</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.  
Avatar of mnb93
mnb93

"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.
Don’t forget to always have the form tag include the enctype=”multipart/form-data”
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-data, 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.

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-data"' set.

http://www.faqts.com/knowledge_base/view.phtml/aid/19252

Hopefully these help.
Avatar of consultgal

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.
ASKER CERTIFIED SOLUTION
Avatar of mnb93
mnb93

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the points, I would also like to know what fixed it?

Steven
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