boo_lolly Posted July 30, 2008 Share Posted July 30, 2008 Hey guys, it's been a while since I've coded in PHP but this is definitely more difficult than it should be. I've got just a small upload form and script, but it's got problems and I don't know where they might be. form <form action="get_file.php" method="post" enctype="multipart/form-data"> Select File: <input type="file" name="uploadFile"> <input type="submit" value="Upload Spreadsheet"> </form> script <?php print "<pre>"; print $_FILES; print "</pre>"; ?> and it prints: Array that's it. I get nothing. At first I had this upload script renaming it and moving the file to a certain location, but it wasn't working. So I cut it all out and I find out that the file wasn't being uploaded at all. So what could be the problem here? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 30, 2008 Share Posted July 30, 2008 Either uploads are not enabled in php.ini or the size exceeds the post_max_size setting. Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted July 30, 2008 Author Share Posted July 30, 2008 ok PHPers I did a little research and found out the issue. Apparently I'm only allowed to upload .jpg image files and they can only be 350kb in size. I want to upload .html and .htm files. Where is this regulation handled? In the php.ini file? Quote Link to comment Share on other sites More sharing options...
vikramjeet.singla Posted July 30, 2008 Share Posted July 30, 2008 try to print out the complete $_FILES array: <?php print "<pre>"; print_r($_FILES); print "</pre>"; ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 30, 2008 Share Posted July 30, 2008 LOL. Did you read the first post in this thread? Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted July 30, 2008 Author Share Posted July 30, 2008 Alright guys. I've got some other stuff going on with this. Last night this script was working, but I had to make a small change this morning. Last night the script was uploading and I found out it was due to directory permissions. The directory of both 'get_file.php' and the .html file I was uploading didn't have write permissions, so I changed that. Then I decided that I didn't want that, I wanted to have another directory inside it called 'public' and change the permissions on THAT to have write permissions, but not the parent directory that I had been uploading it into earlier, successfully. So I make those changes, and now it doesn't work! Here's what I've got. get_file.php <?php $filename = basename($_FILES['uploaded_file']['name']); //print $filename ."<br />"; $ext = substr($filename, strrpos($filename, '.')); //print $ext ."<br />"; if ($ext != ".htm" && $ext != ".html") { print "Invalid filetype. Must be .htm or .html file."; } else { $newname = dirname(__FILE__) ."/public/load_excel". $ext ."<br />"; print $newname; if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $newname)) { print "It's done! The file has been saved as: <a href=\"public/". basename($newname) ."\">". basename($newname) ."</a>"; } else { print "Error: A problem occurred during file upload!"; } } ?> and it prints: /home/httpd/vhosts/mydomain.com/httpdocs/loads/public/load_excel.html Error: A problem occurred during file upload! What's going on here? Why won't it work? The 'loads' directory does not have write permissions (755) but public directory does (777). Why would changing one small thing like that break it entirely? Does anyone see what I'm not seeing? Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted July 30, 2008 Author Share Posted July 30, 2008 ok I saw what the problem was, but it still doesn't work! i had ."<br />"; at the end of $newname and that shouldn't be there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.