Using PHP to create folders on web space and upload files?

Using PHP to create folders on web space and upload files?

am 23.10.2007 22:31:44 von DFS

Hi there,

I use a web-based database which has online forms that users can use to
submit data directly into the database. Each user, when logged into
this database, can submit multiple application forms (usually anywhere
between 1 and 10 submissions).

The only problem is that there is no way for them to upload files with
each of these application forms (as the forms are not that customisable
and the functionality simply isn't there), but I require them to upload
around 7 documents with each form (2 PDF's and 5 JPG images), so I'm
currently looking for workaround to this issue.

The only thing I can do within this fairly rigid form is to create a
hyperlink to my own linux web hosting space, which could contain some
sort of form (via a popup browser window) that would allow the user to
upload these files.

I have around 300 users, and each of their uploaded files should remain
confidential. Therefore, it would be ideal if this form could not only
upload files to my web space, but also create a folder which is named
with their own unique Customer ID (i.e. CUST1234) - then within each
folder, create a sub-folder which is named with each individual
application ID (i.e. APP1234).

Is this something that can be done with PHP? Or should I be looking at
Perl scripts or similar?

I can use the JavaScript on the 'rigid form' to create a dynamic URL
that contains their Customer ID and Application ID (i.e.
mywebsite.com/uploads.php?CustID=CUST1234&AppID=APP1234).

But I'm not sure how I could go about doing this and what
authentication would be required to enable the script to create folders
and upload files into them on my web space? The ability to be able to
view what has already been uploaded into each folder would also be very
useful, as would the intelligence of the script to check if the folder
is create, then if not, create it; or if it is there, simply upload the
files into it.

I don't even know where to start searching for existing scrips that can
do this so help and advice would be appreciated.

Thanks,

Ste

Re: Using PHP to create folders on web space and upload files?

am 24.10.2007 03:45:15 von Jerry Stuckle

Ste wrote:
> Hi there,
>
> I use a web-based database which has online forms that users can use to
> submit data directly into the database. Each user, when logged into
> this database, can submit multiple application forms (usually anywhere
> between 1 and 10 submissions).
>
> The only problem is that there is no way for them to upload files with
> each of these application forms (as the forms are not that customisable
> and the functionality simply isn't there), but I require them to upload
> around 7 documents with each form (2 PDF's and 5 JPG images), so I'm
> currently looking for workaround to this issue.
>

I don't understand why you couldn't modify the forms. It's relatively
simple to put file input elements in an HTML page, and not hard at all
to handle the uploads when they submit the page. Just takes a little
programming.

Or, if it is that hard, maybe you're using the wrong product. It
doesn't do what you want, after all.

> The only thing I can do within this fairly rigid form is to create a
> hyperlink to my own linux web hosting space, which could contain some
> sort of form (via a popup browser window) that would allow the user to
> upload these files.
>

You could do it. But that's going to be an entirely different set of
problems.

> I have around 300 users, and each of their uploaded files should remain
> confidential. Therefore, it would be ideal if this form could not only
> upload files to my web space, but also create a folder which is named
> with their own unique Customer ID (i.e. CUST1234) - then within each
> folder, create a sub-folder which is named with each individual
> application ID (i.e. APP1234).
>

That makes it even rougher. You can't have them in the server's
document root (or subdirectory) as anyone will be able to download them,
just by guessing the name. You could use HTTP authentication to
restrict access to a directory, but for 300 users that will be a
management problem.

> Is this something that can be done with PHP? Or should I be looking at
> Perl scripts or similar?
>

It can be done in PHP, Perl, VBScript or any other language.

> I can use the JavaScript on the 'rigid form' to create a dynamic URL
> that contains their Customer ID and Application ID (i.e.
> mywebsite.com/uploads.php?CustID=CUST1234&AppID=APP1234).
>

Not at all secure.

> But I'm not sure how I could go about doing this and what authentication
> would be required to enable the script to create folders and upload
> files into them on my web space? The ability to be able to view what
> has already been uploaded into each folder would also be very useful, as
> would the intelligence of the script to check if the folder is create,
> then if not, create it; or if it is there, simply upload the files into it.
>

You'll need some authentication. Perhaps the easiest would be to keep
the files somewhere below the document root and have a PHP file deliver
the contents (after authentication, of course).

> I don't even know where to start searching for existing scrips that can
> do this so help and advice would be appreciated.
>

I wouldn't even search for a script. I'd just write it. It would take
less time than finding and adapting someone else's script. It's not all
that much work.

> Thanks,
>
> Ste
>
>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================