Jump to content

noldguy

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

noldguy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Agree with Caeser. The question is way too broad and open ended. It requires (1) knowing how to create HTML forms using the <form> tag and writing a php routine that will (2) validate the data from the submitted form and (3) update the database. That's three different areas of knowledge you have to know. Suggest you do a search for on the terms "php" and "tutorial" and wade through the results. It will take doing your homework, but you'll find what you need to know.
  2. You can't rely on mime type. Try checking the extension instead: [code]if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {   $array = explode(".", $_FILES[$userfile]['name']);   $ext = $array[count($array)-1];   if (!preg_match('/(pdf|ppt)/i', $ext)) {       $message="File is not a PDF or Powerpoint file. Please try another file.<br>";       include("file_manager.inc");       exit();   } } else {   // file was not uploaded error handling code }[/code]
  3. Problem: is_uploaded_file($_FILES['userfile']['tmp_name']) returns false. All $_FILES['userfile'] fields contain "A" (garbage I suppose). I have been unable to get file upload to work. Posted my code to another forum. One member responded saying he saw no problem with the code. Then exchanged 20+ emails with web host tech support. They created the "uplod" directory and set upload_tmp_dir to it's current value. Didn't solve the problem. My test file is a 2.5k gif. I am perplexed, frustrated and at wits end. Anyone have any ideas? [b]Server info (shared host):[/b] [code]Server info (shared host): Apache                      nobody(99)/99 /home/mbiwebor/uplod        99/99          755 /home/mbiwebor/public_html  32050/99        750 file_uploads          on upload_max_filesize    16M post_max_size          8M upload_tmp_dir        /home/mbiwebor/uplod  (note: originally was "no value") open_basedir          /home/mbiwebor/:/usr/lib/php:/usr/local/lib/php:/tmp[/code] [b]Form code[/b] (.htaccess is set so server will parse .html as php) [code]<form enctype='multipart/form-data' action='nomedit.html' method='post'>   <input type='hidden' name='select' value='{$_REQUEST['select']}' />   <input type='hidden' name='nominee_id' value='{$_REQUEST['nominee_id']}' />   <input type='hidden' name='MAX_FILE_SIZE' value='30000' />   <span class='stress small'>Upload photo file</span>   <input class='small' name='userfile' type='file' />   <input class='small' name='upload' type='submit' value='Upload' /> </form>[/code] [b]Processing code[/b] [code]function processUpload() {   global $err_msg;   if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {       $destination = $_SERVER['DOCUMENT_ROOT'] . '/2007/photos' . basename($_FILES['userfile']['name']);       if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $destination)) {         $err_msg = 'File move to photos directory was not successfull';         return;       }   } else {       $err_msg = "File was not uploaded successfully - error code: {$_FILES['userfile']['error']}<br />";       return;   } }[/code] Note that there is more to the processing code that I will add after the upload is working.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.