Multiple File Upload

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple File Upload

Paul Melia
Hi all,
Having fuzzy brain day and need some clarification help with file  
upload.

On page 1, I have two file upload fields...

File 1: <input type="file" name="upload">
File 2: <input type="file" name="upload">

On page 2, I have the following code (from Adam Randall's posting on  
Listsearch.com)...

[var: 'path'='somefilepath']
             [Inline:    -username='username',
                             -password='password']

             [if:(file_uploads->size==0)]

             [else]
                 [iterate: file_uploads, (var:'file')]
                     [var:
                         'actualfilename'=@$file->
(find:'upload.realname'),
                         'tempfilepath'=@$file->(find:'upload.name')]

                     [var: 'doc_name'=
                         (string_replaceregexp:
                         (encode_stricturl: $actualfilename->(split:'\
\')->last),
                         -find='%[\\da-f]{2}',
                         -replace='')]

                     [file_create: $path + $doc_name, -fileoverwrite]
                     [file_write: $path + $doc_name, (file_read:  
$tempfilepath)]
                 [/iterate]
             [/if]

             [/inline]

The question is how do I differentiate between which file is  
associated with which upload?

All possible scenarios may occur: File 1 is empty but file 2 is not,  
vice versa, both have files, none have files.
I want to capture the name of the file associated with each upload  
input so that I can store the name in a corresponding DB field.
ie:
input field 1 -> no file ->  do nothing
input field 2 -> has file ->  get name of file -> store filename in  
file 2 filename field in DB -> put file in proper place

It's probably something very easy and right before my eyes but the  
allergy medicine has really thrown me for a loop today!

Thanks,
Paul

--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Multiple File Upload

Adam Randall
If you are using LP7 or 8, you can use the upload.fieldname to  
differentiate between the upload fields. You'd specify the name of  
the upload by naming the input field.

File 1: <input type="file" name="upload1">
File 2: <input type="file" name="upload2">


[var: 'path'='somefilepath']
             [Inline:    -username='username',
                         -password='password']

             [if:(file_uploads->size==0)]

             [else]
                 [iterate: file_uploads, (var:'file')]
                     [var:
                             'fieldname' = @$file->(find:  
'upload.fieldname'),
                         'actualfilename'=@$file->
(find:'upload.realname'),
                         'tempfilepath'=@$file->(find:'upload.name')]

                                         [$fieldname]<br>

                     [var: 'doc_name'=
                         (string_replaceregexp:
                         (encode_stricturl: $actualfilename->(split:'\
\')->last),
                         -find='%[\\da-f]{2}',
                         -replace='')]

                     [file_create: $path + $doc_name, -fileoverwrite]
                     [file_write: $path + $doc_name, (file_read:  
$tempfilepath)]
                 [/iterate]
             [/if]

             [/inline]

Adam.

--
Adam Randall <[hidden email]>
http://www.omnipilot.com/
(954) 874-3100
AIM/iChat: adamomni

On May 26, 2005, at 12:57 PM, Paul Melia wrote:

> Hi all,
> Having fuzzy brain day and need some clarification help with file  
> upload.
>
> On page 1, I have two file upload fields...
>
> File 1: <input type="file" name="upload">
> File 2: <input type="file" name="upload">
>
> On page 2, I have the following code (from Adam Randall's posting  
> on Listsearch.com)...
>
> [var: 'path'='somefilepath']
>             [Inline:    -username='username',
>                             -password='password']
>
>             [if:(file_uploads->size==0)]
>
>             [else]
>                 [iterate: file_uploads, (var:'file')]
>                     [var:
>                         'actualfilename'=@$file->
> (find:'upload.realname'),
>                         'tempfilepath'=@$file->(find:'upload.name')]
>
>                     [var: 'doc_name'=
>                         (string_replaceregexp:
>                         (encode_stricturl: $actualfilename->
> (split:'\\')->last),
>                         -find='%[\\da-f]{2}',
>                         -replace='')]
>
>                     [file_create: $path + $doc_name, -fileoverwrite]
>                     [file_write: $path + $doc_name, (file_read:  
> $tempfilepath)]
>                 [/iterate]
>             [/if]
>
>             [/inline]
>
> The question is how do I differentiate between which file is  
> associated with which upload?
>
> All possible scenarios may occur: File 1 is empty but file 2 is  
> not, vice versa, both have files, none have files.
> I want to capture the name of the file associated with each upload  
> input so that I can store the name in a corresponding DB field.
> ie:
> input field 1 -> no file ->  do nothing
> input field 2 -> has file ->  get name of file -> store filename in  
> file 2 filename field in DB -> put file in proper place
>
> It's probably something very easy and right before my eyes but the  
> allergy medicine has really thrown me for a loop today!
>
> Thanks,
> Paul
>
> --
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription: http://www.listsearch.com/ 
> lassotalk.lasso?manage
>


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Multiple File Upload

Paul Melia
In reply to this post by Paul Melia
Thanks Adam - I am on Lasso 8, so that will work perfectly!

Paul

On May 26, 2005, at 1:13 PM, Adam Randall wrote:

> If you are using LP7 or 8, you can use the upload.fieldname to  
> differentiate between the upload fields. You'd specify the name of  
> the upload by naming the input field.
>
> File 1: <input type="file" name="upload1">
> File 2: <input type="file" name="upload2">
>
>
> [var: 'path'='somefilepath']
>             [Inline:    -username='username',
>                         -password='password']
>
>             [if:(file_uploads->size==0)]
>
>             [else]
>                 [iterate: file_uploads, (var:'file')]
>                     [var:
>                             'fieldname' = @$file->(find:  
> 'upload.fieldname'),
>                         'actualfilename'=@$file->
> (find:'upload.realname'),
>                         'tempfilepath'=@$file->(find:'upload.name')]
>
>                                         [$fieldname]<br>
>
>                     [var: 'doc_name'=
>                         (string_replaceregexp:
>                         (encode_stricturl: $actualfilename->
> (split:'\\')->last),
>                         -find='%[\\da-f]{2}',
>                         -replace='')]
>
>                     [file_create: $path + $doc_name, -fileoverwrite]
>                     [file_write: $path + $doc_name, (file_read:  
> $tempfilepath)]
>                 [/iterate]
>             [/if]
>
>             [/inline]
>
> Adam.
>
> --
> Adam Randall <[hidden email]>
> http://www.omnipilot.com/
> (954) 874-3100
> AIM/iChat: adamomni
>
> On May 26, 2005, at 12:57 PM, Paul Melia wrote:
>
>
>> Hi all,
>> Having fuzzy brain day and need some clarification help with file  
>> upload.
>>
>> On page 1, I have two file upload fields...
>>
>> File 1: <input type="file" name="upload">
>> File 2: <input type="file" name="upload">
>>
>> On page 2, I have the following code (from Adam Randall's posting  
>> on Listsearch.com)...
>>
>> [var: 'path'='somefilepath']
>>             [Inline:    -username='username',
>>                             -password='password']
>>
>>             [if:(file_uploads->size==0)]
>>
>>             [else]
>>                 [iterate: file_uploads, (var:'file')]
>>                     [var:
>>                         'actualfilename'=@$file->
>> (find:'upload.realname'),
>>                         'tempfilepath'=@$file->(find:'upload.name')]
>>
>>                     [var: 'doc_name'=
>>                         (string_replaceregexp:
>>                         (encode_stricturl: $actualfilename->
>> (split:'\\')->last),
>>                         -find='%[\\da-f]{2}',
>>                         -replace='')]
>>
>>                     [file_create: $path + $doc_name, -fileoverwrite]
>>                     [file_write: $path + $doc_name, (file_read:  
>> $tempfilepath)]
>>                 [/iterate]
>>             [/if]
>>
>>             [/inline]
>>
>> The question is how do I differentiate between which file is  
>> associated with which upload?
>>
>> All possible scenarios may occur: File 1 is empty but file 2 is  
>> not, vice versa, both have files, none have files.
>> I want to capture the name of the file associated with each upload  
>> input so that I can store the name in a corresponding DB field.
>> ie:
>> input field 1 -> no file ->  do nothing
>> input field 2 -> has file ->  get name of file -> store filename  
>> in file 2 filename field in DB -> put file in proper place
>>
>> It's probably something very easy and right before my eyes but the  
>> allergy medicine has really thrown me for a loop today!
>>
>> Thanks,
>> Paul
>>
>> --
>> ------------------------------
>> Lasso Support: http://support.omnipilot.com/
>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>> Manage your list subscription: http://www.listsearch.com/ 
>> lassotalk.lasso?manage
>>
>>
>
>
> --
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription: http://www.listsearch.com/ 
> lassotalk.lasso?manage
>


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Multiple File Upload

Greg Willits
In reply to this post by Paul Melia
Here's a tag that does all that and more for you...

http://www.ldml.org/library/gw_fileuploads.lasso

needs a couple minor () tweaks for LP7/8 I believe.

-- greg willits


On May 26, 2005, at 9:57 AM, Paul Melia wrote:

> Hi all,
> Having fuzzy brain day and need some clarification help with file
> upload.
>
> On page 1, I have two file upload fields...
>
> File 1: <input type="file" name="upload">
> File 2: <input type="file" name="upload">
>
> On page 2, I have the following code (from Adam Randall's posting on
> Listsearch.com)...
>
> [var: 'path'='somefilepath']
>             [Inline:    -username='username',
>                             -password='password']
>
>             [if:(file_uploads->size==0)]
>
>             [else]
>                 [iterate: file_uploads, (var:'file')]
>                     [var:
>                        
> 'actualfilename'=@$file->(find:'upload.realname'),
>                         'tempfilepath'=@$file->(find:'upload.name')]
>
>                     [var: 'doc_name'=
>                         (string_replaceregexp:
>                         (encode_stricturl:
> $actualfilename->(split:'\\')->last),
>                         -find='%[\\da-f]{2}',
>                         -replace='')]
>
>                     [file_create: $path + $doc_name, -fileoverwrite]
>                     [file_write: $path + $doc_name, (file_read:
> $tempfilepath)]
>                 [/iterate]
>             [/if]
>
>             [/inline]
>
> The question is how do I differentiate between which file is
> associated with which upload?
>
> All possible scenarios may occur: File 1 is empty but file 2 is not,
> vice versa, both have files, none have files.
> I want to capture the name of the file associated with each upload
> input so that I can store the name in a corresponding DB field.
> ie:
> input field 1 -> no file ->  do nothing
> input field 2 -> has file ->  get name of file -> store filename in
> file 2 filename field in DB -> put file in proper place
>
> It's probably something very easy and right before my eyes but the
> allergy medicine has really thrown me for a loop today!
>
> Thanks,
> Paul
>
> --
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription:
> http://www.listsearch.com/lassotalk.lasso?manage
>


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage