html - PHP file not handling uploads -
<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>file manager</title> <link rel="stylesheet" href="css/style.css" /> </head> <body> <div id="nav"> <a href="index.php">view</a> | <a href="upload-file.php">upload</a> </div> <h1>file manager — upload files</h1> <form enctype="multipart/form-data" action="upload-file.php" method="post"> <input type="hidden" name="max_file_size" value="50000" /> <p><input type="file" name="uploaded[]"/></p> <p><input type="file" name="uploaded[]"/></p> <p><input type="file" name="uploaded[]"/></p> <p><input type="file" name="uploaded[]"/></p> <p><input type="file" name="uploaded[]"/></p> <p><input type="submit" value="upload" /></p> </form> <?php $target = "upload/"; $target = $target . basename( $_files['uploaded']['name'][0]); $tmpfil = $_files['uploaded']['tmp_name'][0]; $ok=1; if(move_uploaded_file($tmpfil, $target)) { echo "the file ". basename( $_files['uploaded']['name']). " has been upload\ ed"; } else { echo $target . " target<br/><br/>"; echo $tmpfil . " temp<br/><br/>"; print_r($_files); echo "sorry, there problem uploading file."; } ?> </body> </html>
right i'm trying first upload 1 work before keep going, (that;s why im indexing 0), produces output when try upload picture
upload/puppy.jpg target /var/tmp/php9raokg temp array ( [uploaded] => array ( [name] => array ( [0] => puppy.jpg [1] => [2] => [3] => [4] => ) [type] => array ( [0] => image/jpeg [1] => [2] => [3] => [4] => ) [tmp_name] => array ( [0] => /var/tmp/php9raokg [1] => [2] => [3] => [4] => ) [error] => array ( [0] => 0 [1] => 4 [2] => 4 [3] => 4 [4] => 4 ) [size] => array ( [0] => 15404 [1] => 0 [2] => 0 [3] => 0 [4] => 0 ) ) ) sorry, there problem uploading file.
all of scripts , upload/ folder chmoded 777 because didn't remember correct permission , thought should work...
thanks in advance!
perhaps path uploads directory incorrect try full path..
$target = "/your/full/server/path/to/this/dir/upload/";
it permissions issue, turn on php errors or in apache error logs.
Comments
Post a Comment