Forum Moderators: coopster

Message Too Old, No Replies

Users D-loading a dir or its content

How to keep it simple

         

henry0

10:04 pm on Jul 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When a "for a fee" member has registered
a dir and a sub dir is created allowing the member to upload a few pics in his/her sub-dir.
Then I need to give access to each member to their individual sub dir and allow them either (I don't mind so let's deal with the simpler case!) to d-load the whole sub dir ot to open the sub dir and D-load its content

I really do not have a clear vision of the requirements map needed to script that task.

thank you

regards

Henry

jatar_k

10:40 pm on Jul 27, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



so

1. member signs up
2. script creates a dir and subdir - naming convention? Does it match the username?
3. chmod the new dirs to be accessible by the script
4. have a script to read the dir and put links on screen to the contents

that work?

Do you have all the standard user management and login/auth stuff in there too?
are all of your uploads and dir management through scripts?

henry0

11:58 am on Jul 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you
that will work

but I am not too sure about building number #4

yes all the user amangement and other stuffs are in place
It is part of a large system out of which one
a member upon payment get an automated creation of a full set of web pages created that are fully editable within my CMS

my script creates & shmod dir and sub dir named by taking username + # & characters rand
then it can be accessed through a "where ID= etc..."
that indeed is tied to my Auth sys.

I was not really happy in offering only a resize via my CMS, so I isolated the thumb maker and allow my clients to use it for any purpose
therefore a need to let them access Thumb_sub_dir content

also most do not know about win Zip so I need something more direct

thanks again

henry0

1:02 pm on Jul 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let’s rephrase it
Creating a link and a jpeg header is OK
Where I lack the concept is that links need to be dynamically built for I do not know how many pic will be in there (although I think I can deal with that)

But how will the down load be initiated to user’s machine

Thank you

Henry

jatar_k

3:49 pm on Jul 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Maybe the best way is to just let them right click and save

coopster

4:22 pm on Jul 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Or you could script the link and send an app download header. If you want the user to be prompted to save the data you are sending you can use the Content-Disposition header to supply a recommended filename and force the browser to display the save dialog. See PHP header() [php.net] for more info.

henry0

5:25 pm on Jul 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am impressed both mods on duty :)

Thank you

yes this will be my new route

send an app d-load header

but I never had a need to built such a D-load app

is this one a good base to learn from and adapt to my needs

<<< (Credit goes to Zend)
<?
define('FILEDIR', '/mnt/dos/');
$path = FILEDIR . $file;

//check that this file exists and that it doesn't include
//any special characters
if(!is_file($path) OR!eregi('^[A-Z_0-9][A-Z_0-9.]*$', $file))
{
header("Location: error.php");
exit();
}

/*
** //check that the user has permission to download file
** if(user does not have permission)
** {
** //redirect to error page
** header("Location: error.php");
** exit();
** }
*/

$mimetype = array(
'doc'=>'application/msword',
'htm'=>'text/html',
'html'=>'text/html',
'jpg'=>'image/jpeg',
'pdf'=>'application/pdf',
'txt'=>'text/plain',
'xls'=>'application/vnd.ms-excel'
);

$p = explode('.', $file);
$pc = count($p);

//send headers
if(($pc > 1) AND isset($mimetype[$p[$pc - 1]]))
{
//display file inside browser
header("Content-type: " . $mimetype[$p[$pc - 1]] . "\n");
}
else
{
//force download dialog
header("Content-type: application/octet-stream\n");
header("Content-disposition: attachment; filename=\"$file\"\n");
}
header("Content-transfer-encoding: binary\n");
header("Content-length: " . filesize($path) . "\n");

//send file contents
$fp=fopen($path, "r");
fpassthru($fp);
?>