When I use the relative path "../path" It just says "error upploading".
When I put the whole path for the site I get
"Warning: move_uploaded_file(images/article/390601_rotary_art_01.jpg): failed to open stream: No such file or directory in /webroot/e/n/enume001/www/testing/test-blog/admin/add-image.php on line 19
Warning: move_uploaded_file(): Unable to move '/tmp/phpuploads/phpLtloPf' to 'images/article/390601_rotary_art_01.jpg' in /webroot/e/n/enume001/www/testing/test-blog/admin/add-image.php on line 19
Error uploading file"
Code: Select all
<?php
include '../includes/connect.php';
$a_id = $_GET['a_id'];
$uploadDir = '../images/article/';
if(isset($_POST['upload'])) {
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$filePath = 'images/article/' . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
if(!get_magic_quotes_gpc()) {
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$query = "INSERT INTO image (name, size, type, path, a_id)" . "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$a_id')";
mysql_query($query) or die('Error, query failed: ' . mysql_error());
mysql_close();
header ('location:index.php');
}
?>