thedualmind Posted July 23, 2007 Share Posted July 23, 2007 I went through a couple of tutorials before bothering anyone, however I still cannot seem to get past an error from the upload_file_with_validation function. I am new to PHP and I am very eager to learn, however I keep running into walls. I used the Writing A file Upload Class tutorial by BinaryStar which helped me to understand the scripting process much better. My goal right now is just to learn how to get a script to work and there is obviously something I am missing here. I would definitely appreciate anyones help. Here is the script I used. The error message will be posted below it: <?php function upload_file_with_validation() { //SECTION #1 $temp_file_name = trim($this->temp_file_name); $file_name = trim(strtolower($this->file_name)); $upload_dir = $this->get_upload_directory(); $upload_log_dir = $this->get_upload_log_directory(); $file_size = $this->get_file_size(); $ip = trim($_SERVER['REMOTE_ADDR']); $cpu = gethostbyaddr($ip); $m = date("m"); $d = date("d"); $y = date("Y"); $date = date("m/d/Y"); $time = date("h:i:s A"); $existing_file = $this->existing_file(); //<-Add On $valid_user = $this->validate_user(); //<-Add On $valid_size = $this->validate_size(); //<-Add On $valid_ext = $this->validate_extension(); //<-Add On //SECTION #2 if (($upload_dir == "ERROR") OR ($upload_log_dir == "ERROR")) { return false; } elseif ((((!$valid_user) OR (!$valid_size) OR (!$valid_ext) OR ($existing_file)))) { return false; } else { if (is_uploaded_file($temp_file_name)) { if (move_uploaded_file($temp_file_name,$upload_dir . $file_name)) { $log = $upload_log_dir.$y."_".$m."_".$d.".txt"; $fp = fopen($log,"a+"); fwrite($fp," $ip-$cpu | $file_name | $file_size | $date | $time"); fclose($fp); return true; } else { return false; } } else { return false; } } } ?> Error Message Appears to be a directory upload problem: Parse error: parse error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/content/t/h/e/thedualmind/html/policy.php on line 16 Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 23, 2007 Share Posted July 23, 2007 wheres policy.php? and line 16 Quote Link to comment Share on other sites More sharing options...
thedualmind Posted July 23, 2007 Author Share Posted July 23, 2007 it's located in my hosting account under the directory php_uploads/gdforms.php Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 24, 2007 Share Posted July 24, 2007 the error is on that file "/home/content/t/h/e/thedualmind/html/policy.php" and it says maybe your missing } close curly braise or terminator you must post that or u look that file your self Quote Link to comment Share on other sites More sharing options...
thedualmind Posted July 24, 2007 Author Share Posted July 24, 2007 Any ideas on where that file may be found. It appears to be something from MySQL. Also, do you have any ideas on where the curly brace could be missing. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 24, 2007 Share Posted July 24, 2007 this is the file thedualmind/html/policy.php it clear that its located under html forder and look we cant find the error unless we see the code Quote Link to comment Share on other sites More sharing options...
thedualmind Posted July 24, 2007 Author Share Posted July 24, 2007 I think we're getting somewhere . I deleted a file named policy.php in the main html directory. Now when I try to submit the upload on the webpage I get a page now found message which sounds like now we just need to get the right policy.php in the right php folder. Quote Link to comment Share on other sites More sharing options...
thedualmind Posted July 24, 2007 Author Share Posted July 24, 2007 sorry about the misprint. That is a page not found message that I got. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 24, 2007 Share Posted July 24, 2007 I think we're getting somewhere . I deleted a file named policy.php in the main html directory. Now when I try to submit the upload on the webpage I get a page now found message which sounds like now we just need to get the right policy.php in the right php folder. you really need to find the policy.php thats the only way to sort the prob and one thing for sure you have that file or else you wont have that error message Quote Link to comment Share on other sites More sharing options...
thedualmind Posted July 24, 2007 Author Share Posted July 24, 2007 I have the file posted under the following path: /php_uploads/gdforms.php/policy.php. However it seems to only recognize the file being present when it is in the main directory, which is the html directory. You think that my directory setup is not good or maybe my form code is the problem. I can post that if you think that could be an issue. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 24, 2007 Share Posted July 24, 2007 i guess both post a code that you think will sort this out Quote Link to comment Share on other sites More sharing options...
thedualmind Posted July 24, 2007 Author Share Posted July 24, 2007 I got the form to go to the policy.php page after being submitted. However, the files did not seem to get uploaded. On my php script for the parts: $upload_dir = $this->get_upload_directory(); $upload_log_dir = $this->get_upload_log_directory(); Do I need to type in my own directory here. If not, is there anywhere in particular that I need to place my actual directory path in the script Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 24, 2007 Share Posted July 24, 2007 i guess no need but you need to post that class u are using to upload Quote Link to comment Share on other sites More sharing options...
thedualmind Posted July 24, 2007 Author Share Posted July 24, 2007 Now I noticed that while the file is in the html folder, it wll not show any of the php script and therefore will not upload. When it's under the php folder though I get a page not found message. I don't get it. I guess I will have to keep digging. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 24, 2007 Share Posted July 24, 2007 dude it doesnt matter what folder you put the file as long as the code point into the folder or file in the folder you need naming of folder is not an issue 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.