| Microsoft | Articles | Forums | FAQs |
| C# .NET |  |  |  |  |
| VB.NET |  |  |  |  |
| Visual Studio .NET |  |  |  |  |
| ADO.NET |  |  |  |  |
| Xml / Xslt |  |  |  |  |
| VB 6.0 |  |  |  |  |
| .NET CF |  |  |  |  |
| GDI+ |  |  |  |  |
| LINQ |  |  |  |  |
| Deployment |  |  |  |  |
| Security |  |  |  |  |
| FoxPro |  |  |  |  |
| Silverlight / WPF |  |  |  |  |
| Entity Framework |  |  |  |  |
| RIA Services |  |  |  |  |
|
| Web Programming | Articles | Forums | FAQs |
| JavaScript |  |  |  |  |
| ASP |  |  |  |  |
| ASP.NET |  |  |  |  |
| Web Services |  |  |  |  |
|
| Non-Microsoft | Articles | Forums | FAQs |
| NHibernate |  |  |  |  |
| Perl |  |  |  |  |
| PHP |  |  |  |  |
| Ruby |  |  |  |  |
| Java |  |  |  |  |
| Linux / Unix |  |  |  |  |
| Apple |  |  |  |  |
| Open Source |  |  |  |  |
|
| Databases | Articles | Forums | FAQs |
| SQL Server |  |  |  |  |
| Access |  |  |  |  |
| Oracle |  |  |  |  |
| MySQL |  |  |  |  |
| Other Databases |  |  |  |  |
|
| Office | Articles | Forums | FAQs |
| Excel |  |  |  |  |
| Word |  |  |  |  |
| Powerpoint |  |  |  |  |
| Outlook |  |  |  |  |
| Publisher |  |  |  |  |
| Money |  |  |  |  |
|
| Operating Systems | Articles | Forums | FAQs |
| Windows 7 |  |  |  |  |
| Windows Server |  |  |  |  |
| Windows Vista |  |  |  |  |
| Windows XP |  |  |  |  |
| Windows Update |  |  |  |  |
| MAC |  |  |  |  |
| Linux / UNIX |  |  |  |  |
|
| Server Platforms | Articles | Forums | FAQs |
 |  |  |  |  |
| BizTalk |  |  |  |  |
| Site Server |  |  |  |  |
| Exhange Server |  |  |  |  |
| IIS |  |  |  |  |
|
| Graphic Design | Articles | Forums | FAQs |
| Macromedia Flash |  |  |  |  |
| Adobe PhotoShop |  |  |  |  |
| Expression Blend |  |  |  |  |
| Expression Design |  |  |  |  |
| Expression Web |  |  |  |  |
|
| Other | Articles | Forums | FAQs |
| Subversion / CVS |  |  |  |  |
| Ask Dr. Dotnetsky |  |  |  |  |
| Active Directory |  |  |  |  |
| Networking |  |  |  |  |
| Uninstall Virus |  |  |  |  |
| Job Openings |  |  |  |  |
| Product Reviews |  |  |  |  |
| Search Engines |  |  |  |  |
| Resumes |  |  |  |  |
|
| |
|
|
|
| multiple attachments using php mysql |
| R P posted at Tuesday, April 14, 2009 8:34 PM |
Hi,
i wonder where i went wrong here:
if($_POST['getfile3'] != ""){ //insert attachment $fileName = $_FILES['userfile3']['name']; $tmpName = $_FILES['userfile3']['tmp_name']; $fileSize = $_FILES['userfile3']['size']; $fileType = $_FILES['userfile3']['type'];
//echo"<br> go here<br />"; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp);
if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $fetch2 = ("INSERT INTO attachment2 ( tech_id, FileName, FileMime, Filesize, FileData, Created) VALUES ( '$tech_id', '$fileName', '$fileType', '$fileSize', '$content', NOW()) ") or die(mysql_error()); mysql_query($fetch2) or die(mysql_error()); mysql_close(); }
if($_POST['getfile4'] != ""){ //insert attachment $fileName = $_FILES['userfile4']['name']; $tmpName = $_FILES['userfile4']['tmp_name']; $fileSize = $_FILES['userfile4']['size']; $fileType = $_FILES['userfile4']['type'];
$fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp);
if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $fetch2 = ("INSERT INTO attachment2 ( tech_id, FileName, FileMime, Filesize, FileData, Created) VALUES ( '$tech_id', '$fileName', '$fileType', '$fileSize', '$content', NOW()) ") or die(mysql_error()); mysql_query($fetch2) or die(mysql_error()); mysql_close(); } if($_POST['getfile5'] != ""){ //insert attachment $fileName = $_FILES['userfile5']['name']; $tmpName = $_FILES['userfile5']['tmp_name']; $fileSize = $_FILES['userfile5']['size']; $fileType = $_FILES['userfile5']['type'];
$fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp);
if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $fetch3 = ("INSERT INTO attachment2 ( tech_id, FileName, FileMime, Filesize, FileData, Created) VALUES ( '$tech_id', '$fileName', '$fileType', '$fileSize', '$content', NOW()) ") or die(mysql_error()); mysql_query($fetch3) or die(mysql_error()); mysql_close(); } if($_POST['getfile6'] != ""){ //insert attachment $fileName = $_FILES['userfile6']['name']; $tmpName = $_FILES['userfile6']['tmp_name']; $fileSize = $_FILES['userfile6']['size']; $fileType = $_FILES['userfile6']['type'];
$fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp);
if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $fetch4 = ("INSERT INTO attachment2 ( tech_id, FileName, FileMime, Filesize, FileData, Created) VALUES ( '$tech_id', '$fileName', '$fileType', '$fileSize', '$content', NOW()) ") or die(mysql_error()); mysql_query($fetch4) or die(mysql_error()); mysql_close(); }
as you can see all were just the same codings in different fields in a form. i was trying to upload multiple attachments here but php giving me errors or warnings:
Warning: fread(): supplied argument is not a valid stream resource in C:\xampp\htdocs\teamsite\support\tech_submit.php on line 69
Warning: fclose(): supplied argument is not a valid stream resource in C:\xampp\htdocs\teamsite\support\tech_submit.php on line 71
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\teamsite\support\tech_submit.php on line 164
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\teamsite\support\tech_submit.php on line 164
Access denied for user 'ODBC'@'localhost' (using password: NO)
the first attachment had been uploaded but the others were not.
Please help. Thanks in advance! I appreciate it.
-R
|
 |
|
|
| |
|
|
|