Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2004-01-23, 08:32 PM
Eric
Guest
 
Posts: n/a
Default

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());
}
?>
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:50 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.