Forum Moderators: coopster

Message Too Old, No Replies

dynamic upload folder location

         

ineedmoney

7:14 pm on Aug 22, 2006 (gmt 0)

10+ Year Member



Hello, I am trying to write a script that will upload multiple files to a dynamic directory.

I have the upload portion under control (I think) but i can't figure out how to dynamically create the folder the uploads will be stored in.

Basically, I have a form they fill out. I want the name of the folder where the uploads go to be one of the fields they enter in the form.

the path would be
upload/$example/

I hope I am making sense? Is this even possible? Thanks

barns101

7:33 pm on Aug 22, 2006 (gmt 0)

10+ Year Member



mkdir() [php.net] will create a directory.

ineedmoney

7:40 pm on Aug 22, 2006 (gmt 0)

10+ Year Member



Thankyou,

would something like this work?

<?php

$example = $HTTP_POST_VARS['example'];

mkdir("/upload/$example");

$uploadpath = 'upload/$example/';

?>

whoisgregg

10:37 pm on Aug 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm a bit paranoid at times, so I wouldn't trust that the $_POST variable is safe to use as a directory name without doing some sanitizing.

But otherwise, yeah, as long as PHP has privileges to the /upload/ directory, that should work. :)