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? Link to comment https://forums.phpfreaks.com/topic/117270-file-upload-blues/ 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. Link to comment https://forums.phpfreaks.com/topic/117270-file-upload-blues/#findComment-603236 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? Link to comment https://forums.phpfreaks.com/topic/117270-file-upload-blues/#findComment-603240 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>"; ?> Link to comment https://forums.phpfreaks.com/topic/117270-file-upload-blues/#findComment-603287 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? Link to comment https://forums.phpfreaks.com/topic/117270-file-upload-blues/#findComment-603292 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? Link to comment https://forums.phpfreaks.com/topic/117270-file-upload-blues/#findComment-603625 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. Link to comment https://forums.phpfreaks.com/topic/117270-file-upload-blues/#findComment-603666 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.