close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Insert/Update problem using session id for the image file upload

Thread began 9/19/2018 1:34 am by astrostrom | Last modified 9/24/2018 11:34 am by Ray Borduin | 1746 views | 9 replies |

astrostrom

Insert/Update problem using session id for the image file upload

Hi

To avoid umlauts and empty space in image file names, my insert and update forms use the session id to rename the image file. However, if one uploads more than one or two images the current session doesn't update and the same file appears or doesn't appear as it inputs the same file name based on the session id into the DB.Sometimes the new thumbnail is generated but the main image file is not generated with the successive file name.

Is there a work around such as killing the session and starting a new session or is there another method to do this?
Thanks for any help!

Below is the code I am using:
-----------------------------------------------------------------------------

<?php
if (!isset($_SESSION)) {
session_start();
}
?>
<?php require_once('../../Connections/mysqli2.php'); ?>
<?php require_once('../../webassist/mysqli/rsobj.php'); ?>
<?php require_once("../../webassist/file_manipulation/helperphp.php"); ?>
<?php require_once('../../webassist/mysqli/queryobj.php'); ?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../../upload/katalog/",
'FileName' => "". session_id() ."",
'DefaultFileName' => "",
'ResizeType' => "3",
'ResizeWidth' => "",
'ResizeHeight' => "700",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1_2 Start
$WA_UploadResult1_Params["WA_UploadResult1_2"] = array(
'UploadFolder' => "../../upload/katalog/",
'FileName' => "thumb_". session_id() ."",
'DefaultFileName' => "",
'ResizeType' => "3",
'ResizeWidth' => "",
'ResizeHeight' => "150",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_2 End
// WA_UploadResult1 Params End?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1", "image", "2", "[NewFileName]_[Increment]", "JPG:80", $WA_UploadResult1_Params);
}
?>

----------------

$InsertQuery->bindColumn("image", "s", "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."", "WA_DEFAULT");

-----------------

$UpdateQuery->bindColumn("image", "s", "".($WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]) ."", "WA_IGNORE");

-----------------

Sign in to reply to this post

Ray BorduinWebAssist

It looks like it should be set up to rename duplicate files to add _2, _3, etc so that multiple file uploads during the same session would be possible. If you give me a url and FTP access I can debug why that doesn't work properly for you.

Sign in to reply to this post
Did this help? Tips are appreciated...

astrostrom

As mentioned, the thumbnail image is being generated and the new file name (increment) is being written to the DB but the new image files is not being generated. Also, I get a DW error message when I click on the Upload Files server behavior (File Manipulation Upload Wizard) :

"It appears that one of your server-side values is improperly coded. Please check this interface for inconsistencies."

The URL and FTP access are in separate PM.

Thanks.

Sign in to reply to this post

astrostrom

Info in PM

Sign in to reply to this post

Ray BorduinWebAssist

I just tested the insert page and uploaded three images and both the thumbnail and image were uploaded with increments to the server. I'm looking in the upload folder and I can see it has worked for you several times in the past as well. Maybe it just isn't working in certain circumstances? Maybe it is a problem on the update page? I'm going to need more information in order to reproduce the problem before I can tell you why it happens. What steps are you following when you see this issue? Maybe it has something to do with the image you are uploading?

Sign in to reply to this post
Did this help? Tips are appreciated...

astrostrom

Dear Ray

Many thanks for having a look. Yes, it is very curious when something works and then doesn't work. When this occurred with my client, I tried to reproduce the problem by uploading and updating various images via his catalog interface. I also looked at the code and compared it with other similar examples.

This one client is the only one who has reported this problem so far. However, I only recently started using the session id for renaming the image files. He is using Windows 10 / Firefox.

When inserting and updating images on my personal catalog, I did not experience the same problem immediately - I added and updated 4 or 5 images - but when I tested using my client's images the problem appeared again after about 8 or 9 uploading/updating sessions. So maybe there is something uniquely strange with the image files. Attached are several of his original images.(See PM)

Sign in to reply to this post

astrostrom

My client mentioned in the previous e-mail has been adding additional images and the problem has surfaced again.
See screenshot of DB in private mail.

Thanks for your attention and help.

Sign in to reply to this post

Ray BorduinWebAssist

Code is usually consistent. Odd issues that occur inconsistently like this are usually because of something changing by the user and not something changing in the code... code usually doesn't change.

So, the only thing that I can think of is that it has something to do with the images that the user is uploading. Since they are using the same process for each image and the only thing that would change is the image being uploaded.

The key to solving any problem is to reproduce it. I tried my hardest to reproduce the problem with the files you provided. I took the three images you gave and uploaded each one 8 times, so I had a total of 24 files uploaded and didn't see any problems. The 24 images were uploaded (I disabled the database insert since it didn't appear to be part of the problem).

I'm thinking that maybe if I got a zip of all of the images they are trying to upload I could use those to reproduce the problem. What I really need is steps to reproduce the issue. Once I can see a problem, I can almost always fix it. But without seeing it in my trials, I can't really figure out what to change or test if any changes work since I can't see the problem in the first place.

Sign in to reply to this post
Did this help? Tips are appreciated...

astrostrom

Dear Ray

Again, many thanks again for looking deeper into this problem. I, too, tried to reproduce the problem with my own images but could not. So I tend to agree that this is a probably user specific problem. So far, only this one user has reported the problem.

Over the weekend, I tried to optimize the code by using code from another similar set of pages and it seems to me that it is now working. At least with my own image files. Perhaps, that is why you did not experience any issues if you only looked today.

One thing I did notice was that the File Manipulation "Upload Files" server behavior generated a slightly different code for setting the session id for the file name than an earlier earlier version of Data Bridge.

New:
'FileName' => "thumb_\". session_id() .\"",

whereas the backslash escapes the quotes

Previous:
'FileName' => "thumb_". session_id() ."",

I am using the older previous code now on the working pages. I don't know if this is relevant.

Sign in to reply to this post

Ray BorduinWebAssist

The new code above seems wrong. The escaped quotes will cause the file to be named with the literal text and not the true session id value.

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...