Jump to content

Help! Apple Scripts to use with WebStar's file uploading...


Krishan
 Share

This topic is 7480 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi.

I have created a private message board system so users can have a one-to-one conversation with just me. There are three databases: Users.fp5, Topics.fp5 and Messages.fp5. The databases are related using the UserID, TopicID and MessageID fields. So far it works great but the user cannot upload images via Web Companion. If I use WebStar's file upload plug-in then I'll need to create a link for the path to the ftp folder. I think as long as a folder contains the ".upload" text file WebStar will allow file uploading.

I need applescripts to help with my message board (a message board that allows people to add images). I'd be grateful if anybody could help me out.

Using applescript, my idea is this:

When a new record is created in my Users.fp5 database, I want to automatically create a new folder (within my "images" folder situated at the root of my server). I want this new folder to be automatically named with the UserID (a field in my Users.fp5) associated with that particular record.

giving me the path... "images/[FMP-field: UserID]/"

When a new record is created in my Topics.fp5 database, I want to automatically create a new folder (within that individual user's "UserID" folder). I want this new folder to be automatically named with the TopicID (a field in my Topics.fp5) associated with that particular record.

I also want this "TopicID" folder to contain the standard .upload txt file that webstar requires to enable users to upload files to this folder.

giving me the path... "images/[FMP-field: UserID]/[FMP-field: TopicID]/.upload"

On the Internet, when a user creates a new topic the first page he sees will allow the submission of "text" via Web Companion. After he submits the text and FMPro creates a -new record in the Topics.fp5 database, the user will be taken to the second web page which allows the uploading of images to accompany only his Topic (text).

The form for uploading images to accompany that specific text just submitted would be:

<FORM ENCTYPE="multipart/form-data" ACTION="/images/[FMP-field: UserID]/[FMP-field: TopicID]/x.upload" METHOD=POST>

Use the Browse button to select a file.

<P>File: <INPUT NAME="remotefile" TYPE="file">

<P><INPUT TYPE="submit" VALUE="Send this image">

<INPUT TYPE="reset" VALUE="Reset">

</FORM>

On the Internet, when the user views his newly created topic the webpage will contain the text he wrote and then the link (which will open in a new window) to "http://mydomain/images/[FMP-field: UserID]/[FMP-field: TopicID]/".

When a new record is created in my Messages.fp5 database, I want to automatically create a new folder (within images/"UserID"/"TopicID"/). I want this new folder to be automatically named with the MessageID (a field in my Messages.fp5) associated with that particular record.

I also want this "MessageID" folder to contain the standard .upload txt file that webstar requires to enable users to upload files to this folder.

giving me the path... "images/[FMP-field: UserID]/[FMP-field: TopicID]/[FMP-field: MessageID]/.upload"

On the Internet, when a user creates a new message the first page he sees will allow the submission of "text". After he submits the text and FMPro creates a -new record in the Messages.fp5 database, the user will be taken to the second web page which allows the uploading of images to accompany only his message.

The form for uploading images to accompany that specific text just submitted would be:

<FORM ENCTYPE="multipart/form-data" ACTION="/images/[FMP-field: UserID]/[FMP-field: TopicID]/[FMP-field: MessageID]/x.upload" METHOD=POST>

Use the Browse button to select a file.

<P>File: <INPUT NAME="remotefile" TYPE="file">

<P><INPUT TYPE="submit" VALUE="Send this image">

<INPUT TYPE="reset" VALUE="Reset">

</FORM>

On the Internet, when a user views this newly created message (i.e. viewing the Topic record in the Topics.fp5 database but using portals to view the Messages associated with that record) the message will contain the text and then the link (which will open in a new window) to "http://mydomain/images/[FMP-field: UserID]/[FMP-field: TopicID]/[FMP-field: MessageID]/".

Thus each Message will have their own folder for uploading images and I won't have the problem of two files having the same name and replacing each other upon uploading. It will also mean that you can only view the directory of images in the folder associated with the specific topic or message you're reading.

I'd really appreciate any help! Will this work??

If you think it will work, can anyone help me with the applescripts required?

Thanks!

Link to comment
Share on other sites

Hi,

I had a long look at this, because it would be a really useful function I'd like to use myself, but I can't see an immediate way to do it (at least, it's beyond me!)

If the purpose is to

1 stop users seeing one another's files

2 stop files being overwritten

then there's a simple workround for doing this from only one directory:

Set up the ftp access to only allow logon and upload files - users then won't see the contents of the image folder

Set the image name field to require a unique value and have the error reply page tell them that the file name's already taken and please choose another.

As a safeguard, you can set ftp to not overwrite files with the same name.

Not elegant, but it's a quick stopgap while you work out a way to create directories.

Jeff

Link to comment
Share on other sites

This topic is 7480 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.