Ok my code below uploads the file just fine but it says Can't Copy File! even though the file is in the directory on the server it is suppose to be in. Also, it wont execute the sql statement for some reason because it says 'You have an error in your sql syntax near ')' on line 1' Anyone know what is going on here?
Also the $conn variable is in the check_login.php script so dont worry about it.
Code:
<?php
include("check_login.php");
print("<form action=\"{$_SERVER['PHP_SELF']}\" " .
"method=\"post\" enctype=\"multipart/form-data\">\n" .
"<input type=\"hidden\" name=\"ACTION\" " .
"value=\"POST\">\n" .
"<b>Image File:</b><br>" .
"<input type=\"file\" name=\"inputFile\"><br>" .
"<b>Exact Client Username to view project.</b><br>" .
"<input type=\"text\" name=\"clientUser\"><br>\n" .
"<input type=\"submit\" value=\"Add Project\">" .
"</form>\n");
/*
* Perform actions to add project.
*/
if(isset($_POST['ACTION']))
{
$username='ftpuser';
$password='ftppass';
$host='ftphost';
$path='/armedpenguin.net/phptesting/clientImages/';
$conn_id = ftp_connect($host);
$login_result = ftp_login($conn_id, $username, $password);
if ((!$conn_id) || (!$login_result)) {
die("Connection to FTP failed!");
}
$upload = ftp_put($conn_id, $path . $_FILES['inputFile']['name'], $_FILES['inputFile']['tmp_name'], FTP_BINARY);
if (!$upload) {
die("FTP upload has failed!");
}
ftp_close($conn_id);
if(!move_uploaded_file($_FILES['inputFile']['tmp_name'], "/armedpenguin.net/phptesting/clientImages/".$_FILES['inputFile']['name']))
{
print("Can't move uploaded file!");
}
if(!$conn)
{
die("Couldnt connect to database!");
}
if(!mysql_select_db($dataBase,$conn))
{
die("Couldnt connect to database!");
}
$filedata = addslashes(file_get_contents("/armedpenguin.net/phptesting/clientImages/".$_FILES['inputFile']['name']));
$sql = "INSERT INTO clientImg(User, Img) VALUES ($clientUser, $filedata)";
mysql_query($sql) or die(mysql_error());
}
?>