Page 1 of 2
PDF File Upload
Posted: Wed Oct 14, 2009 9:49 am
by bsouthuk
Hi wonder if someone can help me.
I have created an application in studio 3.5 and wanted to upload a PDF file so that users are able to open the PDF when they click on a button.
Is this easily done on revolution?
Cheers
Daniel
Posted: Wed Oct 14, 2009 1:16 pm
by Janschenkel
Assuming that you're uploading to an FTP server, it can be a one-liner like
Code: Select all
put URL("binfile:" & tLocalPath) into URL("ftp://user:password@example.org/" & tRemotePath)
It's always safest to read files to upload as binary files.
HTH,
Jan Schenkel.
Posted: Wed Oct 14, 2009 2:31 pm
by bsouthuk
Thanks Jan
Is there not a way of uploading my PDF file to my stack in RunRev like I would do my website and then for a user to click a button for the PDF to open?
Just not too sure about this FTP server. I have a linux based hosted website. Going by your code if my
username is bsouthuk
password is manutd07
domain is porrima-qg.com
file name that i have uploaded to my site is QG.PDF
Then should the exact code be:
Code: Select all
put URL("binfile:" & tLocalPath) into URL("ftp://bsouthuk:manutd07@porrima-qg.co.uk/qg.pdf" & tRemotePath)
Is this right?
And when you click on the button, the PDF file will show in a browser?
Cheers
Dan
Posted: Wed Oct 14, 2009 3:23 pm
by BvG
I really hope these are not real login credentials... If they are, I advise to edit your post and REMOVE THEM IMMEDIATELY!!!
Maybe you meant not "upload" (which is always to a server) but "store" (for example within a stack)
you can do that:
Code: Select all
set the storedPDF of this stack to url ("binfile:" & "somefile.pdf")
put the storedPDF of this stack into url ("binfile:" & "someotherfile.pdf")
launch "someotherfile.pdf"
Posted: Wed Oct 14, 2009 4:12 pm
by bsouthuk
Ha no they are not real!
Thanks very much for this now all I need to know is how do I store my PDF in my stack?
Posted: Wed Oct 14, 2009 4:50 pm
by Mark
Hi bsouthuk,
BvG already answered your question:
Code: Select all
set the storedPDF of this stack to url ("binfile:" & "somefile.pdf")
Best,
Mark
Posted: Wed Oct 14, 2009 4:58 pm
by bsouthuk
I think i'm having a blonde moment hear.
The name of my pdf file is "o2.pdf"
Therefore am I right in saying that I type the following code in a button and it will store the PDF that I have saved on my desktop and open the PDF file when I click the button?
The code I have is:
Code: Select all
set the storedPDF of this stack to url ("binfile:" & "o2.pdf")
put the storedPDF of this stack into url ("binfile:" & "o2.pdf")
launch "o2.pdf"
Is this right?
Posted: Wed Oct 14, 2009 5:08 pm
by Mark
bsouthuk,
Set the storedPDF property from the message box, using the first line. Make sure that the path to the PDF is correct. Probably it should be something like "C:/folder/folder/o2.pdf" instead of simply "o2.pdf".
In your button, you can use the remaining two lines. Again, make sure that you use a correct path, e.g. to the temp directory or to the desktop. The launch command needs a correct file path too.
If you try your code and get errors, post the errors in this forum.
Best,
Mark
Posted: Wed Oct 14, 2009 6:55 pm
by bsouthuk
Thanks Mark though having some problems - when i click on the button, nothing actually happens.
In the button I have the following code:
Code: Select all
on mouseUp
put the storedPDF of this stack into url ("binfile:" & "C:/Users/Daniel Shapiro/Desktop/Daniel/Commercials/O2/Business tariff and bundle Pricing.pdf")
launch "C:/Users/Daniel Shapiro/Desktop/Daniel/Commercials/O2/Business tariff and bundle Pricing.pdf"
end mouseUp
In the stack property inspector under 'custom properties' it says 'StoredPDF" then underneath this in the'properties context' box it has the following some crazy lines of code which looks chinese or something. Thousands of lines!
Then in the 'External references' the following:
C:/Users/Daniel Shapiro/Desktop/Daniel/Commercials/O2/Business tariff and bundle Pricing.pdf
What am I doing wrong?
Cheers
Dan
[/code]
Posted: Wed Oct 14, 2009 7:00 pm
by Mark
Hi Dan,
Do you use Mac OS X or Windows?
Normally, you should not hardcode the filepath. You should create the filepath using a system-dependent component and a file-dependent component. For example:
specialfolderpath("temp") & "/someuniquefilename.pdf"
specialfolderpath("desktop") & "/yourpdf.pdf"
item 1 to -2 of the effective filename of this stack & "/yourpdf.pdf"
et cetera...
Best,
Mark
Posted: Wed Oct 14, 2009 7:08 pm
by bsouthuk
Hey Mark
I use windows.
In the filepath section under 'external references' I add the file path. Are you saying to delete this?
Is everything I have done correct.
Sorry but when you say to create the filepath using a system-dependand component and give some examples it makes no sense to me!
Posted: Wed Oct 14, 2009 7:33 pm
by bn
Hi Daniel,
shouldn't that be
Code: Select all
launch document "C:/Users/Daniel Shapiro/Desktop/Daniel/Commercials/O2/Business tariff and bundle Pricing.pdf"
instead of
Code: Select all
launch "C:/Users/Daniel Shapiro/Desktop/Daniel/Commercials/O2/Business tariff and bundle Pricing.pdf"
? Could you try this? You might want to look up 'launch' and 'launch dokument' in the dictionary.
regards
Bernd
Posted: Wed Oct 14, 2009 8:45 pm
by bsouthuk
Thanks Bernd now Acrobat opens but I get the following error message:
Adobe reader could not open 'QG.pdf' because it is either not a supported file type or because the file ahas been damaged.
I have tried this with 3 other PDF files so can you spot where I am giong wrong?
Posted: Wed Oct 14, 2009 8:54 pm
by bsouthuk
...And strangely enough I cant open the PDF files but double clicking them on my desktop now - the same error message is displayed.
What on earth am i doing wrong here?
Posted: Wed Oct 14, 2009 8:58 pm
by Mark
bsouthuk,
The launch document command should work. I have had, hwoever, quite a few problems with it on Windows XP and Vista.
Try something like this:
Code: Select all
put specialfolderpath(desktop) & "/Commercials/O2/Business tariff and bundle Pricing.pdf" into myFilePath
if there is a file myFilePath then
set the hideConsoleWindows to true
put "start" && quote & quote && quote & myFilePath & quote into myShell
get shell(myShell)
else
beep
answer "Can't find file" && myFilePath
end if
Best,
Mark