rawky1976 Posted March 23, 2007 Share Posted March 23, 2007 <?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 More sharing options...
Lumio Posted March 23, 2007 Share Posted March 23, 2007 put error_reporting(E_ALL); after <?php and post all errors and notices you'll get Link to comment https://forums.phpfreaks.com/topic/44045-whats-wrong-with-this-upload-script/#findComment-213863 Share on other sites More sharing options...
rawky1976 Posted March 23, 2007 Author Share Posted March 23, 2007 So the beginning of it now reads: - <?php error_reporting(E_ALL); $uploadDir = '/upload/'; I don't get any errors though? Should they display on the webpage? Link to comment https://forums.phpfreaks.com/topic/44045-whats-wrong-with-this-upload-script/#findComment-213869 Share on other sites More sharing options...
DeathStar Posted March 23, 2007 Share Posted March 23, 2007 just me or should there always be session_start(); first? Link to comment https://forums.phpfreaks.com/topic/44045-whats-wrong-with-this-upload-script/#findComment-213871 Share on other sites More sharing options...
rawky1976 Posted March 23, 2007 Author Share Posted March 23, 2007 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? Link to comment https://forums.phpfreaks.com/topic/44045-whats-wrong-with-this-upload-script/#findComment-213872 Share on other sites More sharing options...
rawky1976 Posted March 23, 2007 Author Share Posted March 23, 2007 Im testing it locally on another PC (on my LAN) the DB is on there too. The conn string is still set to localhost. That's where the DB will be right? Link to comment https://forums.phpfreaks.com/topic/44045-whats-wrong-with-this-upload-script/#findComment-213874 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.