Jump to content

What's wrong with this upload script?


rawky1976

Recommended Posts

<?php

$uploadDir = '/upload/';

 

if(isset($_POST['uploadform']))

{

$fileName = $_FILES['userfile']['name'];

$tmpName = $_FILES['userfile']['tmp_name'];

$fileSize = $_FILES['userfile']['size'];

$fileType = $_FILES['userfile']['type'];

$filePath = $uploadDir . $fileName;

$result = move_uploaded_file($tmpName, $filePath);

if (!$result) {

echo "Error uploading file";

exit;

}

 

include '../library/config.php';

include '../library/opendb.php';

if(!get_magic_quotes_gpc())

{

$fileName = addslashes($fileName);

$filePath = addslashes($filePath);

}

$query = "INSERT INTO document (name, size, type, path, keywords, about) ".

"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$_POST[keyWords]', '$_POST[about]')";

mysql_query($query) or die('Error, query failed : ' . mysql_error());

include '../library/closedb.php';

 

echo "<br>Files uploaded<br>";

}

?>

 

Nothing in the upload folder and nothing in the DB?

Link to comment
https://forums.phpfreaks.com/topic/44045-whats-wrong-with-this-upload-script/
Share on other sites

Sorry, this is above it: -

 

<?php

session_start();

 

if (!isset($_SESSION['db_is_logged_in'])

  || $_SESSION['db_is_logged_in'] !== true) {

 

      header('Location: loginFailure.php');

  exit;

}

?>

 

That checks the user is logged in, do I need it again in the next block of code?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.