2 Replies Latest reply on Oct 16, 2008 10:07 PM by (chrisbleak)

    Image upload and insert into database

    Level 1
      I am attempting to insert a record into my images_uploaded_by_user table but I have been having problems for several days. Image uploads have been working perfectly with another site on the same server, which is why I am so confused by the error.

      What seems to be the problem is that the image upload and insert transaction is not receiving the file name or file extension from wherever it gets it when I try to upload.

      This is the error I receive
      File upload error: Invalid file name. File name is empty. (FILE_UPLOAD_ERROR)

      I have tried using automatic renaming and manual renaming, but either way the details of the file do not make it as far as the insert transaction

      If you have any ideas what might be happening I would be very glad to hear from you.
        • 1. Re: Image upload and insert into database
          Waleed Barakat Level 1
          Hi, can you give a piece of the error code?
          • 2. Re: Image upload and insert into database
            Level 1
            here is the full page code, i would not normally do this as i know how it makes a post too complicated , but this error is killing me. <br /> <br />I have included the error at the bottom. thankyou for any help in advance. <br /> <br /><?php require_once('../Connections/mywebsitedb.php'); ?> <br /><?php<br />// Load the common classes<br />require_once('../includes/common/KT_common.php');<br /><br />// Load the tNG classes<br />require_once('../includes/tng/tNG.inc.php');<br /><br />// Make a transaction dispatcher instance<br />$tNGs = new tNG_dispatcher("../");<br /><br />// Make unified connection variable<br />$conn_mywebsitedb = new KT_connection($mywebsitedb, $database_mywebsitedb);<br /><br />// Start trigger<br />$formValidation = new tNG_FormValidation();<br />$tNGs->prepareValidation($formValidation);<br />// End trigger<br /><br />//start Trigger_ImageUpload trigger<br />//remove this line if you want to edit the code by hand <br />function Trigger_ImageUpload(&$tNG) {<br />  $uploadObj = new tNG_ImageUpload($tNG);<br />  $uploadObj->setFormFieldName("Filedata");<br />  $uploadObj->setDbFieldName("image_name");<br />  $uploadObj->setFolder("../logged-in/profile/images/user_images/");<br />  $uploadObj->setMaxSize(1500);<br />  $uploadObj->setAllowedExtensions("gif, jpg, jpe, jpeg, png");<br />  $uploadObj->setRename("auto");<br />  return $uploadObj->Execute();<br />}<br />//end Trigger_ImageUpload trigger<br /><br />//start Trigger_Redirect trigger<br />//remove this line if you want to edit the code by hand<br />function Trigger_Redirect(&$tNG) {<br />  $redObj = new tNG_Redirect($tNG);<br />  $redObj->setURL(KT_getFullUri());<br />  $redObj->setKeepURLParams(false);<br />  return $redObj->Execute();<br />}<br />//end Trigger_Redirect trigger<br /><br />// Make an insert transaction instance<br />$ins_images_uploaded_by_users = new tNG_insert($conn_mywebsitedb);<br />$tNGs->addTransaction($ins_images_uploaded_by_users);<br />// Register triggers<br />$ins_images_uploaded_by_users->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");<br />$ins_images_uploaded_by_users->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);<br />$ins_images_uploaded_by_users->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "FILES", "Filedata");<br />$ins_images_uploaded_by_users->registerConditionalTrigger("{GET.isFlash} != 1", "END", "Trigger_Redirect", 90);<br />$ins_images_uploaded_by_users->registerTrigger("AFTER", "Trigger_ImageUpload", 97);<br />$ins_images_uploaded_by_users->registerConditionalTrigger("{GET.isFlash} == 1", "ERROR", "Trigger_Default_MUploadError", 10);<br />// Add columns<br />$ins_images_uploaded_by_users->setTable("images_uploaded_by_users");<br />$ins_images_uploaded_by_users->addColumn("image_name", "FILE_TYPE", "FILES", "", "");<br />$ins_images_uploaded_by_users->setPrimaryKey("unique_image_id", "NUMERIC_TYPE");<br /><br />// Execute all the registered transactions<br />$tNGs->executeTransactions();<br /><br />// Get the transaction recordset<br />$rsimages_uploaded_by_users = $tNGs->getRecordset("images_uploaded_by_users");<br />$row_rsimages_uploaded_by_users = mysql_fetch_assoc($rsimages_uploaded_by_users);<br />$totalRows_rsimages_uploaded_by_users = mysql_num_rows($rsimages_uploaded_by_users);<br /><br />// Multiple Upload Helper Object<br />$muploadHelper = new tNG_MuploadHelper("../", 32);<br />$muploadHelper->setMaxSize(1500);<br />$muploadHelper->setMaxNumber(0);<br />$muploadHelper->setExistentNumber(0);<br />$muploadHelper->setAllowedExtensions("gif, jpg, jpe, jpeg, png");<br />?> <br /> <br /> <br /> <br /> <br /> <br /> <script src="../includes/common/js/base.js" type="text/javascript"></script> <br /> <script src="../includes/common/js/utility.js" type="text/javascript"></script> <br /> <script src="../includes/skins/style.js" type="text/javascript"></script> <br /><?php echo $tNGs->displayValidationRules();?><?php echo $muploadHelper->getScripts(); ?> <br /> <br /> <br /> <br /><?php<br /> echo $tNGs->getErrorMsg();<br />?> <br /><?php<br />// Multiple Upload Helper<br />echo $tNGs->getSavedErrorMsg();<br />echo $muploadHelper->Execute();<br />?> <br /> <br /> <br /> <br />ERROR PAGE <br /> <br />Error: <br />File upload error: Invalid file name. <br />Developer Details: <br />File upload error: Invalid file name. File name is empty. (FILE_UPLOAD_ERROR) <br />tNG Execution Trace - VIEW <br /> <br /> * tNG_insert.executeTransaction <br /> o STARTER.Trigger_Default_Starter <br /> o STARTER.Trigger_Default_Starter <br /> o tNG_insert.doTransaction <br /> + BEFORE.Trigger_Default_FormValidation <br /> + tNG_insert.prepareSQL <br /> + tNG_insert.executeTransaction - execute sql <br /> + tNG_insert.postExecuteSql <br /> + AFTER.Trigger_ImageUpload* <br /> + ERROR.Trigger_Default_MUploadError