Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Need help File Upload:

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need help File Upload:

    To All:
    Does anyone have an a5w page or component that they are willing to share that does the following.

    I would like to upload a PDF file to a directory([PathAlias.ADB_{Path]\pdf).
    This would be a packing slip for a purchase order.There would be a hyperlink on the screen to view packing slips.
    depending on the PO that the user is viewing it would open up the correct pdf file.

    I can upload jpg files into an image table and then view that image.(desktop and web)

    But my thinking is the packing slip does not have to be in a table(image file ref)
    Just upload to a folder and either browse that folder and allow the user to select the one to view or use a hyperlink to open the correct file.

    I can do this in a desktop app , but I am having trouble with the web app.


    Thanks
    Charlie Crimmel

    #2
    Re: Need help File Upload:

    Got it working thanks

    Comment


      #3
      Re: Need help File Upload:

      Would you mind sharing your solution, Charlie. I have a similar need to upload pdfs to a file and not a table.

      Comment


        #4
        Re: Need help File Upload:

        This is my wish list for Alpha Five. Make things easier for users like me who don't know Xbasic coding, to be able to upload files and images into folders and tables.

        Comment


          #5
          Re: Need help File Upload:

          Chuck,
          If there is a feature you see that is absent, then post it in the Wishlist forum as Alpha most likely will see your wish much sooner there than in a forum post. But make sure you clarify as it sure seems like you are referencing a desktop term when you say "tables" and this is a web forum. If you are referring to doing this in the desktop, then create a new thread in the appropriate forum as what you want can be done with Action Script.
          Mike
          __________________________________________
          It is only when we forget all our learning that we begin to know.
          It's not what you look at that matters, it's what you see.
          Henry David Thoreau
          __________________________________________



          Comment


            #6
            Re: Need help File Upload:

            Hello,

            I would like to be able to also upload a PDF to a file and be able to view the document from a link in a grid.
            Can you tell me how you accomplished this or how it works?

            Thanks.

            Comment


              #7
              Re: Need help File Upload:

              In a rare show of good sense, I engaged Pat Bremkamp to create the functions for me. The result is exactly what I wanted. My requirements were the ability to identify and upload files to specific ID numbers so that users can complile a library of documents related only to that ID.

              If you don't need to identify the document uploads to specific user files, the simple upload code from the Help works well:

              <html>

              <%a5

              dim msg as c = ""

              if eval_valid("cmd")

              file.from_blob(ServerSetting.Document_Root + "\\" + FileToUpload.filename, FileToUpload.data)

              msg = "<a href=\"/" + FileToUpload.filename + "\" target=\"_blank\">" + FileToUpload.filename + "</a> was uploaded<br /><br />"

              end if

              %>

              <head>

              <title>File Upload example</title>

              </head>

              <body bgcolor="#ffffff">

              <%a5 ? msg %>

              <form action=" <%a5 ? request.script_name %> " method="POST" enctype="multipart/form-data">

              <input type="file" name="FileToUpload" value=""><br />

              <input type="submit" name="cmd" value="Upload File">

              </form>

              </body>

              </html>

              Comment


                #8
                Re: Need help File Upload:

                Hello,

                I've been beating my head against the wall now for almost a day, trying every combination I can think of...

                What I'm trying to accomplish is very similar to the above however...

                I would like to create a directory under the /webroot/ of the {id} number of the record... then simply upload images into that directory... (something like /webroot/67/

                This way I can have a simple a5w (where I pass a variable like "67" to it), displays EVERY image in the directory (this a5w page works perfectly).

                I'm just having trouble uploading images to the target directory... I'm attempting to pass the variable name to the a5w page through the url...

                IF eval_valid("cmd")
                file.from_blob(ServerSetting.Document_Root + "\\" + id + "\\" + FileToUpload.filename, FileToUpload.data)
                msg = "<a href=\"/" + FileToUpload.filename + "\" target=\"_blank\">" + FileToUpload.filename + "</a> was uploaded<br /><br />"
                END IF

                However, even though the directory exists, I still get an error saying 'id' has no value...

                Here is what I'm trying to work through...

                http://localhost/photo_upload2.a5w?id=67

                after pressing the "upload" button... I get
                500 Internal Server Error
                "Script Error
                Error:Script: /photo_upload2.a5w line:8
                file.from_blob(ServerSetting.Document_Root + "\\" + id + "\\" + FileToUpload.fi
                Variable "id" not found."


                Am I missing something basic here, or any suggestions?

                Thanks,!
                Bill

                Comment


                  #9
                  Re: Need help File Upload:

                  IF eval_valid("cmd")
                  file.from_blob(ServerSetting.Document_Root + "\\" + id + "\\" + FileToUpload.filename, FileToUpload.data)
                  msg = "<a href=\"/" + FileToUpload.filename + "\" target=\"_blank\">" + FileToUpload.filename + "</a> was uploaded<br /><br />"
                  END IF
                  Bill I don't see in this code How id i s getting a value

                  ----------------------
                  My attack on this situation is slightly different
                  I'll show you via pseudo||proto code

                  Code:
                  IF eval_valid("cmd")  then
                    Dim tblUpl as P
                    Dim id as C
                    Dim ImageREFer as C 
                    tblUpl = table.open("[theAlias]PdfRecs.dbf",RW_EXCLUSIVE)
                      tblUPl.Enterbegin()
                        id = Ltrim(Str(TblUpl.id)
                         ImageREFer = ServerSetting.Document_Root + "\\" + id + "\\" 
                                          +FileToUpload.filename
                        file.from_blob(ImageREFer, FileToUpload.data)
                       tblUPl.ImageRef = ImageREFer 
                  tblUpl.EnterEnd
                  tblUpl.Close()
                  end if
                  Note that code is full of syntax errors eg pseudo||proto code,
                  The idea is that you need to open a table at the same time as you save the BLOB. My preference is to actually rename the file to a new name rather than creating a directory. But in reality they are the same thing.
                  The ImageRef just means you don't need to recalculate the file and Directiory name. Thus if you are going to search||sort this will assist later.

                  Good Luck!

                  Comment


                    #10
                    Re: Need help File Upload:

                    Thanks Colin...

                    I guess I have to back-up a bit, because I think we are attempting the same thing, but I'm approaching it without using the database at all.

                    To explain... So far I've created a A5W page that displays photo's in a directory...

                    I call the photos.a5w like this from a link in my table...
                    http: //localhost/photos.a5w?address=20 cherry st

                    This is the code as it stands so far for photos.a5w... (I've altered it to use "address" instead of id...)
                    Code:
                    <%a5
                    'Do the header
                    ? "<font size='12'><strong>" + address + "</font></strong>"
                    
                    'Figure out the source directory prefix into 'dr'
                    dr="/photos/" + address + "/"
                    temp=a5.get_path() + dr
                    
                    ? "<br>"
                    ? "<br>"
                    ? "<br>"
                    
                    cr="\photos\\" + address + "\\"
                    create=a5.get_path() + cr
                    'If there is no directory with the address created, then create it.
                    
                    if file.exists(create) = .f.
                    	file.dir_create_recurse(create)
                    	'? "<br>Directory Created!"
                    end if
                    
                    'file.dir_create(create)
                    
                    ? "<br>"
                    
                    'Grab the directory listing into ff, and ready to parse
                    ff = filefind.get(temp + "\*.jpg", FILE_FIND_NOT_DIRECTORY, "N")
                    ff = filter_stringc(ff,"a5wcmp",crlf(),.t.)
                    ? "<br>"
                    ? "<br>"
                    
                    i=0 ' prepare counter, in case there are none, (for message below)
                    
                    for each foo in ff
                    	? "<strong>"+foo+"</strong><br>"
                    	? "<image src=\""+dr+foo+"\"><br><br>"
                    	i=i+1 ' count iterations
                    next
                    
                    if i=0 then ' if there are no photos, then display the error message.
                        ? "No photos uploaded for " + address
                    end if
                    %>
                    I figure this is a quick and dirty way to display photos in any directory I pass the photos.a5w.

                    All seems to work well on the localhost.

                    If I pass it variable address="20 cherry st", then it will create a directory on the localhost called "/photos/20 cherry st". Consequently any photos I put in "/photos/20 cherry st" get displayed if I call the same a5w page.

                    Currently, I am manually copying photo's into the respective directory on the server manually. However I would like to be able to upload the photos via a browse button (preferrably specify up to 10 files, then click upload), the script would then confirm that the "address" directory is created (if not already), and upload the files into that directory.

                    I realize this is somewhat unconventional, but I don't want the photo-files in the database, and storing a "path" to the photos in the database seems redundant as it is nice to see a plain english path to the photos too.

                    I guess I have two questions... (now that I have uploaded this to the main server to play with it) (On the remote server, it doesn't create directories!... It doesn't display files!) (I would suspect this has something to do with some PathAlias, or permissions somewhere?)

                    1) Get this a5w to function on the local AND remote server.

                    2) Get another a5w to upload photos based on passing it an "address" variable... so user can upload photos to whatever directory is specified with the variable passed i.e. /upload.a5w?address=20 cherry st

                    I'm a relative beginner in A5 (but am familiar with VB), so just usually need a nudge in the right direction.

                    Thanks for any suggestions!
                    Bill
                    Last edited by billkay; 04-11-2009, 08:12 AM.

                    Comment


                      #11
                      Re: Need help File Upload:

                      Bill,

                      Since you are talking about addresses, you may be interested in a site I built for a small real estate association http://www.dalharttxmls.com

                      Here are some lessons learned from that:

                      1. All the photos go in a single directory named (very creatively) "photos"

                      2. If different people will be entering photos, then you can't control what they name their photo, so I change the name. If the MLS number for the address is L00802, then I rename the phots L00802.1.jpg, L00802.2.jpg, and so on up to 6. (I chose 6 photos per property for no particularly good reason. The same setup works for any number.) If they want to replace a photo, say number 2, they just upload a new number 2 and it overwrites the old number 2. Another hint: don't use any spaces in the directory name or the photo name. You'll avoid a lot of trouble that way.

                      3. I use a separate upload page with a spot for photo 1 and caption 1, then photo2 and caption 2, etc. The people using this site have various levels of computer expertise, so this seems easiest to understand.

                      4. I put in instructions about photo size, and this is almost universally ignored.

                      5. I use the image file reference and don't try to put the photos in the table. So far, they have over 9 meg in photos, and that's just a small town. You don't want your tables that large!

                      Have fun!

                      Pat
                      Pat Bremkamp
                      MindKicks Consulting

                      Comment


                        #12
                        Re: Need help File Upload:

                        Bill,
                        Okay I'm a bit lost now,
                        but
                        note
                        Code:
                        if file.exists(create) = .f.
                        Sometimes I have found needs to be written, as
                        Code:
                        if file.exists(create) = .f. then
                        Without the keyword then I have found the interpreter may skip the conditional code.

                        Comment


                          #13
                          Re: Need help File Upload:

                          Ok.. sorry.. thanks for the tip... i've updated the a5w, and will make sure I don't make that mistake again...

                          Maybe I should start a new thread on my situation... I don't mean to confuse things...

                          Thanks,
                          Bill

                          Comment


                            #14
                            Re: Need help File Upload:

                            I was hoping that Charlie Crimmel will post the solution he used.

                            Comment


                              #15
                              Re: Need help File Upload:

                              here is the code on my send email button (Desktop Version) that saves the Purchase order as a PDF file.
                              The entire PO app is 4.5 + meg zipped.
                              It is to big to attach, but I will give it to anyone who might want to use it as a learning tool.

                              Just leave a private message with your email.
                              I will send a stripped down version of the Purchase Order Application that has been in use for a year and a half.

                              I also have a web version

                              Charlie Crimmel
                              (Desktop Version)
                              dim global vname as c
                              dim global vdept as c
                              dim global vcomp as c
                              dim global voffice as c
                              dim global vfax as c
                              dim global vcell as c
                              dim global vemail as c
                              var->vname = ""
                              var->vdept = ""
                              var->vcomp = ""
                              var->voffice = ""
                              var->vfax = ""
                              var->vcell = ""
                              var->vemail = ""

                              var->vname = ""
                              var->vdept = ""
                              var->vcomp = ""
                              var->voffice = ""
                              var->vfax = ""
                              var->vcell = ""
                              var->vemail = ""

                              t1=table.current(1)
                              dim global vfilename as C
                              dim global vpath as C
                              dim global vsaveas as C
                              var->vfilename=""
                              var->vpath=""
                              var->vsaveas=""
                              var->vpath="C:\Alpha5v9\BSE_Purchase\PDF"+chr(92)
                              var->vfilename=trim(Poheader->PO_NUMBER)+"-"+substr(DTOC(Poheader->Date),1,2)+substr(DTOC(Poheader->Date),4,2)+substr(DTOC(Poheader->Date),9,2)+".pdf"
                              var->vsaveas=var->vpath+var->vfilename
                              'Print a report, label, letter, form or browse layout. You can specify which records to print.
                              record_number = current_record_number()
                              'query.filter = "recno() = " + record_number
                              current_filter = "recno() = " + record_number
                              current_order = ""
                              query.filter = current_filter
                              query.order = current_order
                              ':Report.SaveAs("POPDF","PDF",query.filter,query.order,"testrfq.pdf",.F.)
                              :Report.SaveAs("POPDF","PDF",query.filter,query.order,var->vsaveas,.F.)

                              Comment

                              Working...
                              X