Hi, I need a php function on a website I'm building allowing upload of .docs and .pdfs. I found the code below on the net and am trying to use it. I created a file called "FILES" on my server and tried it out but without luck. I understand php very little so if someone can point out what I'm doing wrong in simple terms I'd appreciate it.
if (!is_dir("files")) { if (!mkdir($upload_dir)) die ("upload_files directory doesn't exist and creation failed"); if (!chmod($upload_dir,0755)) die ("change permission to 755 failed."); }
//File Size Check if ( $_FILES['userfile']['size'] > $MAX_SIZE) $message = "The file size is over 2MB."; //File Extension Check else if (!in_array($file_ext, $FILE_EXTS)) $message = "Sorry, $file_name($file_type) is not allowed to be uploaded."; else $message = do_upload($upload_dir, $upload_url);
Without an action attribute the form should default to itself, but yes it's best to include it.
In the past I've always specified the exact file path, not relative. The function for this is getcwd(), something that's fairly difficult to find on php.net without knowing its name.