View Full Version : DFP2 questions
kbettenc296716
05-14-2009, 11:11 AM
The documentation does not indicate whether or not there is a difference setting up the file upload for an insert page or an update page. The "default" file field on the second page of DFP2 does not seem to retain the data. I place the name of the hidden image field using the lightning bolt icon like I did with DFP1, it accepts it, but doesn't write it to the code and when I go back again it is gone. the "default" field is not even mentioned in the online help files.
I was able to get it to write the filename to the database once by deleting the server behavior (DFP1) and redoing it in DFP2. Now for some reason it doesn't work at all, the file gets uploaded but the information is not written to the database.
Ray Borduin
05-14-2009, 11:38 AM
Please post a support incident. I'm not sure if this is a bug or problem with the way it is applied and that is the fastest way to get someone to debug it with you directly.
fragop363190
05-14-2009, 03:03 PM
It is definetely a bug. I have run into it allready just wasnt sure if i had to post it into forums too.
DFP2 Default File is not writing code to the page for the "default file". That is why it "doesnt retain the code". It actually does not exist so the behavior can find it.
If you click finish after u select a Default File no code will be written to your page.
You can confirm it by double clicking on the upload behavior and checking the default file field which is empty.
Allready submited a ticket, please guys this is a major bug, resolve it asap cause whenever u update a page using update.php or inserting a new row using a default image, the default image not being inserted in db and ofc on update.php the original filename is deleted from db since it doesnt contain the hidden form field with old data.
Please give us a minor release fast.
Ray Borduin
05-14-2009, 03:12 PM
Another user today had an issue and setting the default value fixed it for them... There must be more to this than meets the eye. We will certainly create a fix quickly to resolve an issue like this once we can reproduce the cause. Thank you for submitting a support incident that will get the ball rolling toward understanding and eventually fixing the problem.
muddysmurf
05-14-2009, 06:31 PM
Is this sorta the same thing as when I finally got everything to work.. sometimes it uploads my images into the database and sometimes it doesn't?
If i go back into insert record and choose the correct settings, save and try it again, it will work..but then stop after a few tries.
fragop363190
05-14-2009, 11:14 PM
Ok this is the code so you see for yourself what i mean.
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../assets/images/logos/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "1",
'ResizeWidth' => "150",
'ResizeHeight' => "100",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["Insert_x"])){
WA_DFP_UploadFiles("WA_UploadResult1", "image_cmp", "2", "[NewFileName]_[Increment]", "JPG:80", $WA_UploadResult1_Params);
}
?>
I used a default file/image. Do you see any parameter for it?
'DefaultFileName' => "" is empty.
Ok if i manually add this line and give a path and ofc the image name...then if you open the DFP2 upload behavior you will see that it has the path u entered...
So problem 1 solved...but...
Even with default file defined, the insert feature (i tried it only on insert.php) ignores this parameter and if it doesnt find anything in the file browse form element it just doesn't insert anything to the image column.
So DFP2 bug 1 = not inserting code under the 'DefaultFileName' => "" parameter. Even if you make it manualy so it recognises, if you go change it again, u will see again the code you had manually inserted.
bug2. Unsolved - Something wrong in DFP2 code and it doesnt even use the parameter. I will try diggin up in the include files to find the "WA_DFP_UploadFiles" fynction and check code there in order to speed up the resolving of this issue. If someone has found out sth plz post it asap.
Ray Borduin
05-15-2009, 06:40 AM
Maybe try changing focus out of the field before clicking OK. It will sometimes take the default parameter, so the question is why it sometimes doesn't in your case.
Please post a support incident and we can have an engineer contact you and debug this with you more. This is not typical or a known issue.
muddysmurf
05-15-2009, 07:11 AM
I know I posted last night about sometimes it was uploading and working and other times it wasn't, well I tried it twice here on my work computer and it seemed to have worked.
Do you think my problem may have something to do with maybe a cache problem from Firefox? I didn't try it on IE last night, so I really don't know this for sure or not. I have the newest version of Firefox.
fragop363190
05-15-2009, 07:15 AM
Even if i manualy edit the code for the default file, it doesnt take it into account into DFP insert or update pages.
It just doesnt insert the default file name to the database when the file browse form field doesnt have anything in it. So it simply doesn't work as intended.
At least not to my system and i don't have DFP1 installed (i uninstalled it first) neither ADT. I only got WebAssist Web Development Suite installed nothing else currently.
Ray Borduin
05-15-2009, 07:26 AM
I see. OK that sounds like it could be a bug. Please post a support incident and we can have someone look into this problem.
The easiest solution for now is to use two update server behaviors. One to update all of the other fields and one to update the upload field. Then use the trigger of a successful uplaod in the second update so that the update of the file field doesn't take place if no file is specified.
I will look into the reported issue as a bug. Thank you for bringing it to my attention.
fragop363190
05-15-2009, 09:42 AM
Could you please elaborate this further?
Thanks in advance
Ray Borduin
05-15-2009, 10:02 AM
Which part?
Apply 2 update database server behaviors.
in the first one only update the upload field and use the upload success trigger
in the second update all of the fields except the upload field and use the button press trigger
only set the redirect in the second one. If you need more description, please be specific about what doesn't make sense.
SOJO web
05-16-2009, 01:02 AM
fragop,
I submitted a support incident for this and was informed it had been elevated to the engineers. It seems there may be two issues. Number one is that when you select a default file, the extension only puts the code in your "update/insert" page some of the time. Number is two is that when the default image is there - it still doesn't make any difference as far as maintaining a default value for the database.
I hope this gets worked out soon.
fragop363190
05-16-2009, 02:02 AM
Logic thank you for your answer. I got exactly the same problem. Ill try today to resolve it with the temporary fix, if you make it work please inform me via this post.
Ill get right into it and ill post you what i did exactly if it works or what problem i run to.
I opened a ticket too and waiting for the updated version.
fragop363190
05-16-2009, 10:39 AM
Ok in HelperPHP.php file (in WA_DigitalFilePro folder) there are 2 functions.
Function 1: WA_DFP_UploadFiles() with a comment that is V2
Function 2: WA_DFP_UploadFile() which if im correct is V1 of DFP.
Function 1 doesnt give specific arguements and uses all the arguements passed dynamicaly while function 2 (DFP1) has specific arguements where u can see that a $defaultFileName variable is passed.
Along the lines function 2 has this code for the "else {" statement (this is the else statement for when there is no file uploaded at all)
else{
$WA_DFP_UploadStatus[$statusName]["statusCode"] = 0;
$WA_DFP_UploadStatus[$statusName]["serverFileName"] = '';
$path_parts = pathinfo($defaultFileName);
$WA_DFP_UploadStatus[$statusName]["fileExtension"] = '';
$WA_DFP_UploadStatus[$statusName]["errorMessage"] = "No file uploaded";
$_SESSION[$sessionName] = $defaultFileName;
}
Function 1 has this code under the same else statement :
else{
$WA_DFP_UploadStatus[$statusName]["statusCode"] = 0;
$WA_DFP_UploadStatus[$statusName]["errorMessage"] = "No file uploaded";
$_SESSION[$sessionName] = '';
}
As you see there is NO $defaultFilename or anything passed as the sessionName on the new DFP2 function so it is normal it does't work correctly. The code is not complete. Also in DFP2 function there is no variable such as $defaultFilename geting the $WA_UploadResult1_Params['DefaultFileName'] data (its the path tha u choose under the Default File in the upload behavior of DFP2 (that doesn't work, currently u have to manually write it in the variable).
So even if the above code was correct which is incomplete, again the above parameter is not geting interpreted in the DFP2 function so its normal there is no using of Default File.
P.S. $defaultFileName in DFP1 holds all the path to the file not only the filename. To get filename should be sth like "$path_parts = pathinfo($defaultFileName);" (mentioned above) and $path_parts['basename'] so it could be inserted to db.
P.S.2 I might be missing code parts, my plan is not to say anything bad about product just to help fix this issue very fast cause its a major bug and DFP2 shouldn't be released with it. Hope this post helps your developers or another developer in WebAssist community and get up with a quick fix.
SOJO web
05-16-2009, 05:55 PM
fragop,
That is some excellent sleuth work! That's what we need is for the function to be complete. I guess we could probably write the necessary code. I will toy around with it.
fragop363190
05-17-2009, 04:02 AM
Ok this is the SOLUTION for DataAssist created page with 1 and only 1 file browser and the default file (usually u use it for images no display etc) should be allready uploaded in folder since it doesnt upload it and it SHOULDN't. For me, the Default File in DFP2 wizzard that let's you browse is a mistake since its only use is for images and u can just put a file on server and just type the name of file there. In upload.php that wizard works properly, it uses only filename not path. So having a file field is a waste and mixing up some people probably. Let it a TextField and just type the name of the image to be used if nothing uploaded.
I will NOT work with more than 1 and i will explain why.
1. BUG#1 : at insert.php whatever you do it will not write down your DefaultFileName parameter. You need to manualy edit the line at the
"$WA_UploadResult1_Params["WA_UploadResult1_1"] = array("
DefaultFileName parameter and write the Full Name of the file.
The line should look like -- 'DefaultFileName' => "no_image.jpg", --
I use a no_image.jpg for my records without logo.
This bug does not exist for some reason in the update.php page. If you insert a DFP2 upload behavior over there it will put that line for you correctly. Don't ask me why im not the developer of the extension and the code is in the .MXP i can't check it.
2. BUG#2 : HelperPHP.php is faulty (for DFP2 at least, didn't use at all DFP1 even if I had it). HelperPHP.php has both DFP1 & DFP2 functions. DFP2 basic function is WA_DFP_UploadFiles() while DFP1 is WA_DFP_UploadFile (watch for the s at DFP2).
There is missing code for the DefaultFileName in DFP2's function (i didnt check DFP1 function at all only as a basic stepup so dont know what is happening there).
Solution :
A.Go at aproximately line number 300+ u will find the function's ELSE statement that occurs if there is no file to be uploaded (u didn't select anything in the file field in the form). There should be an else statement sth like the below code.
else{
$WA_DFP_UploadStatus[$statusName]["statusCode"] = 0;
$WA_DFP_UploadStatus[$statusName]["errorMessage"] = "No file uploaded";
$_SESSION[$sessionName] = '';
}
B. Change it to the below code - basically you are adding 2 lines.
else{
$fileParameters = func_get_arg(5);
$WA_DFP_UploadStatus[$statusName]["statusCode"] = 0;
$WA_DFP_UploadStatus[$statusName]["errorMessage"] = "No file uploaded";
$_SESSION[$sessionName] = '';
$WA_DFP_UploadStatus[$statusName]["serverFileName"] = $fileParameters['WA_UploadResult1_1']['DefaultFileName'];
}
Comments.
I notice this thing. When i did put an upload behavior in insert.php it wrote in HelperPHP.php. Then after i finished with the insert.php i did same thing to update.php and again it wrote in HelperPHP.php. I am assuming that it just overwrites file so to be sure that HelperPHP.php exists. This means that you fix both your insert and update.php pages with the upload behavior and THEN u edit the HelperPHP.php file or you will loose the code you added. Also keep the code somewhere in a text file cause whatever you do you will probably end up overwriting that helper file again so u just go there and edit it pasting the proper code. You could also rename it as HelperPHP_fixed.php probably and edit the include file above your pages so even if webassist overwrites HelperPHP.php your application wont be affected. All this assuming that HelperPHP is never changing and it is same always. A WebAssist tech could tell us about it so we just rename it its better and safer.
This could be posted as minor bug if this is the case and WebAssist products using that file should check if it exists and if it exists they should skip the copy process so it doesnt modify our file.
Agai I repeat this is a TEMPORARY FIX for 1 FILE FIELD in DataAssist Wizard's generated pages, didn't test it to other pages nor i will cause i'm out of time.
The reason that it is only for 1 file field it is that the DFP2 main function send all parameters via an arguement with an array called "$WA_UploadResult#_Params".
This is an associative array and cause u might have multiple fields the HelperPHP.php functions need to be able to process all fields. So i have handcoded at the code the
$WA_DFP_UploadStatus[$statusName]["serverFileName"] = $fileParameters['WA_UploadResult1_1']['DefaultFileName'];
check 'WA_UploadResult1_1' which should be taken ny a variable that resolves inside a loop so to address all File Fileds in form. As i don't want to use more time and go to further testing currently, cause i suppose now Technicians can fix it up soon properly and not as my fix i won't even trying looping it. If someone has time to play with it and you find the proper code working for multiple fields post it here :)
fragop363190
05-17-2009, 04:38 AM
Ok guys i added delete file behaviors on both update.php and detail.php (carefull it overwrites HelperPHP.php again so keep backup of either the 2 lines code or a file and just rename it on your server).
What was worrying me after checking the delete function is that i don't see anywhere checking the DefaultFileName attribute again so not to delete it. Well code doesn't check about it but its probably not needed on linux servers, on windows u need to hack the code to check about the name.
On linux servers you get an owner on the uploaded files of 99. while if u upload from ftp any file you will get owner of the credentials you used to login to ftp.
DELETE function can not delete the no_image.jpg on my webserver cause it can't delete a file from my user. Can only delete file from user 99. In a windows server environment i suppose u need to hack the above function in HelperPHP.php file
This is the original code in HelperPHP.php
function WA_FileAssist_DeleteFile($folderPath, $filePath){
$folderPath = rootRelativeToFullFileURL($folderPath);
$result = FALSE;
$separator = WA_DFP_GetFileSeparator();
$path = $folderPath.$separator.$filePath;
$fullPath = realpath($path);
if(file_exists($path) && is_writable($fullPath)){
unlink($fullPath);
$result = TRUE;
}
return $result;
}
You should probably change the IF arguement -- if(file_exists($path) && is_writable($fullPath)) -- to :
if(file_exists($path) && is_writable($fullPath) && ($filePath!='no_image.jpg'))
Ofc this is an example. In reality you need to pass to the DELETE function the DefaultFileName value as a parameter and use a variable instead of the hard-coded no_image.jpg. This means that DELETE function needs to change a bit and a parameter specific for it should be adde to code cause e.g. details.php page doesnt have any defaultfilename parameter so the delete function could use.
It is not a tough fix but i don't need it currently as im using a linux webserver. You could also handcode it as i showed u if ur working with images. You dont need loop here, just give the name of the DefaultFileName for no image and IF should check if that is the filename. If it is, it wont bother deleting the file at all.
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.