close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

file upload help

Thread began 1/21/2010 2:00 pm by info357532 | Last modified 1/26/2010 1:43 pm by Eric Mittman | 2109 views | 8 replies |

info357532

file upload help

I am trying to configure PowerStore 2 to upload pdf files in admin panel for my client and have had zero luck getting past the validator for image uploads using the DigitalFilePro Helper.php...and yes im aware that a pdf is not an image file (in most instances)...my reasoning is to utilize the same upload file array structure, minus the height/width constraints, validate the file type as a pdf, upload file to directory, & place file array into products db. Error received thus far I believe is in validating the file type as a pdf, tried many edits to the Helper.php with no luck, does anyone have any suggestions or simple solution?

Sign in to reply to this post

Eric Mittman

You will not be able to use Digital File Pro to validate the file type if it is not an image. Instead you should make use of a Server Validation for the file type to ensure that it is a pdf. You would then have a standard Digital File Pro upload that is not checking for the file to be an image.

This will allow you to confirm that the file is a pdf before it is uploaded, then the upload will occur. You can then use any of the bindings from the upload in a db insert or update by going to the bindings and expanding the upload entry.

To apply the server validation you will need to have Validation Toolkit or CSS Form Builder installed.

Sign in to reply to this post

miav solutions

Eric,
I guess I am still clueless, so I am going to try to walk through this, I only ask for your patience...perhaps I am putting to much thought into this and it is far more simple then I am seeing it.
I have attached my Admin/Products_Insert.php file for your inspection, perhaps you will be able to clarify where I am in error.

Attached Files
Products_Insert.zip
Sign in to reply to this post

neilo

What is it that your client wants to do with the pdf once it is uploaded? If you merely want to upload the pdf to the server, you could do it from the insert/update pages in any of the cart / short/ long description fields by clicking the 'link' button, selecting 'browse the server' and and from there selecting the browse and upload buttons. This should upload the pdf as a file and not an image.

The you can either choose to link to it or not, but the pdf will be uploaded to your server for whatever use you want to put it to.

Sign in to reply to this post

miav solutions

neilo,
thanks for your reply, unfortunitly I want the upload process to be as simple as possible for my client, embedding links within the descriptions just adds to the confusion of an already confussed customer...not what I want to deal with so just to keep things simple I am adding an additional upload label for the products insert and update pages, this way the customer has to upload a pdf (which the customer utilizes for floor plans) and it is simple for the customer to do, just like adding/editing an image for a product. Thankfully I have a simple way around the problem I was having...

Many thanks to Eric for taking the time to understand my issues, and neilo, thanks for the input...the problem was resolved by editing the WA_DFP_SetupUploadStatusStruct(""); I had to set it to FALSE instead of TRUE, end result of edit:

<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadXXX1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadXXX1", "PATH", "2", "[NewFileName]_[Increment]", "false", $WA_UploadXXX1_Params);
}
?>

everything else is setup just like if you wanted to add an additional image (including labels & validation stuffs)...see attachment within this topic for full code on Products_Insert.php

this only took me oh, almost 2 weeks to sort through...its always something so simple...

Sign in to reply to this post

miav solutions

Guess I wasn't quite done with this, okay so I can the PDF file to upload fine, my problem now is getting the recordset to display the file name in the DB instead of just a number? I get the number 1 in the fieldset when a PDF file is uploaded instead I need the file name to be written to the recordset...

any suggestions?

Sign in to reply to this post

Eric Mittman

What are you storing in the db for the file? In your insert or update server behavior you should be storing the file name and maybe even the server file path.

When you are getting the number 1 what table does this value come from? If this id is to represent the unique identifier for the file name stored in a separate table then you will need to join this table and the one that contains the filename.

Please post back and include the details about how you are storing the file name including the tables and relationships of the info in them.

Sign in to reply to this post

miav solutions

Eric,
I am trying to get the same information entered into the DB file that is entered for an image file (more strictly just the name of the file), in reality all I need is the file name of the .pdf file uploaded to be entered into the DB recordset upon completion of upload.

I have inserted into the products table a field for "FLOOR PLANS", this field needs to contain the name of the .pdf file uploaded. The floor plan is called through a direct link, i.e. <a href="../PDF/Upload/<?php echo $row_WADAProducts['ProductFloorPlan']; ?>">Floor Plans</a>. and opens the .pdf file in a seperate browser window when clicked.

So far I am able to get the .pdf file to upload with only one problem, the recordset for $row_WADAProducts['ProductFloorPlan'] is being set with the value of "1" to which I do not know why and for the life can not figure out why.

Below is the code used in the Products_Insert.php & Products_Update.php for the image (in this case file) parameters array.

<?php
// USED TO CREATE ARRAY TO STORE FLOORPLAN FILE LOCATION INTO DB
// WA_UploadFloorPlan1 Params Start
$WA_UploadFloorPlan1_Params = array();
// WA_UploadFloorPlan1_1 Start
$WA_UploadFloorPlan1_Params["WA_UploadFloorPlan1_1"] = array(
'UploadFolder' => "../PDF/Upload/",
'FileName' => "[FileName]",
'DefaultFileName' => "");
// WA_UploadFloorPlan1_1 End
// WA_UploadFloorPlan1 Params End?>
<?php
// LOADING FLOORPLAN PARAMS INTO UpLoadeStatusStruct
WA_DFP_SetupUploadStatusStruct("WA_UploadFloorPlan1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadFloorPlan1", "ProductFloorPlan", "2", "[NewFileName]_[Increment]", "false", $WA_UploadFloorPlan1_Params);
}
?>

I am not sure if any of the above is the issue however I can tell you that when I set the WA_DFP_UploadFiles("xxx","xxx","x","[xxx]_[xxx]","FALSE","xxx") instead of true I am able to upload the .pdf file without error except for the value="1". If this remains as "true" the error generated is my best guess an "invalid image file" and will not allow the uploader to progress past the error...
...I am able to bi-pass this issue by manually setting the recordset using MySQL with the file name however this is defeating the purpose...

Sign in to reply to this post

Eric Mittman

The way this should be setup is to have the upload server behavior on the page first. You should not have any image file restrictions in place in this server behavior. This should allow you to get the pdf uploaded.

Next you will add in your insert or update server behavior. You can set the trigger of this server behavior to all uploads successful so that it will not insert or update if the uploads do not occur. In this server behavior for the ProductFloorPlan column you will want to bind the server file name from the upload bindings.

When setup like this you should be able to fill in the form, have the file upload, then have the insert or update occur with the server file name. Please post back and let me know how you have things setup compared to this overview. If you have any part of this that is setup differently let me know. Also if you continue to have problems with this please post back with the insert and update pages and the table structure in a sql file. I can use these files to do some testing to help determine what may be wrong.

Sign in to reply to this post

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...