[PHP] Creating a Directory
Hello, I am using the following script to upload files to my server. Is there anyway I can create a directory (on the fly) for the new image to go, as I want people to be able to upload files with the same name. Thanks $uploadDir = 'uploads/'; $uploadFile = $uploadDir . $_FILES['form_data']['name']; print pre; if (move_uploaded_file($_FILES['form_data']['tmp_name'], $uploadFile)) { print File is valid, and was successfully uploaded. ; # print Here's some more debugging info:\n; #print_r($_FILES); } else { print File is invalid. ; # print Possible file upload attack! Here's some debugging info:\n; # print_r($_FILES); } print /pre;
RE: [PHP] Creating a Directory
[snip] Hello, I am using the following script to upload files to my server. Is there anyway I can create a directory (on the fly) for the new image to go, as I want people to be able to upload files with the same name. [/snip] You know that manual thingie? It's awersome! http://us3.php.net/mkdir -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating a directory
What's the best way to create a directory with PHP, I tried using: if (array_exists('dir',$_POST)) { $dir_name = test123; shell_exec('mkdir $dir_name'); I don't want to have to declare a variable, I would like to do this all on one line. Like: shell_exec('mkdir $_POST['dir']'); // but it don't work } else { print Get get some coffee!; } I'll be putting some error checking in later :) Thanks, Dan. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating a directory
Use mkdir in PHP Functions. See Also: http://www.php.net/manual/en/function.mkdir.php On Fri, 12 Nov 2004 03:54:52 -0500, Danny Brow [EMAIL PROTECTED] wrote: What's the best way to create a directory with PHP, I tried using: if (array_exists('dir',$_POST)) { $dir_name = test123; shell_exec('mkdir $dir_name'); I don't want to have to declare a variable, I would like to do this all on one line. Like: shell_exec('mkdir $_POST['dir']'); // but it don't work } else { print Get get some coffee!; } I'll be putting some error checking in later :) Thanks, Dan. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating a directory
On Friday 12 November 2004 08:54, Danny Brow wrote: What's the best way to create a directory with PHP, I tried using: if (array_exists('dir',$_POST)) { $dir_name = test123; I'm 99% sure you mean 'test123'. shell_exec('mkdir $dir_name'); I'm 100% sure you meant to use instead of '. } else { print Get get some coffee!; I'm 50% sure that should be print RTFM. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* I like your SNOOPY POSTER!! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating a directory
Thanks, I should have looked that up. 4am, time for bed. Thanks again, Dan. On Fri, 2004-11-12 at 18:01 +0900, Pluance wrote: Use mkdir in PHP Functions. See Also: http://www.php.net/manual/en/function.mkdir.php On Fri, 12 Nov 2004 03:54:52 -0500, Danny Brow [EMAIL PROTECTED] wrote: What's the best way to create a directory with PHP, I tried using: if (array_exists('dir',$_POST)) { $dir_name = test123; shell_exec('mkdir $dir_name'); I don't want to have to declare a variable, I would like to do this all on one line. Like: shell_exec('mkdir $_POST['dir']'); // but it don't work } else { print Get get some coffee!; } I'll be putting some error checking in later :) Thanks, Dan. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating a directory
On Fri, 2004-11-12 at 17:12 +, Jason Wong wrote: On Friday 12 November 2004 08:54, Danny Brow wrote: What's the best way to create a directory with PHP, I tried using: if (array_exists('dir',$_POST)) { $dir_name = test123; I'm 99% sure you mean 'test123'. I meant $dir_name = $_POST['dir']; This works with out the single quote. but all my variables have single or double quotes around them. shell_exec('mkdir $dir_name'); I'm 100% sure you meant to use instead of '. this is how I normally do this when declaring variables, but that maybe the difference here. } else { print Get get some coffee!; I'm 50% sure that should be print RTFM. RTFM /dev/null :) I'm 25-50% sure that this was a complete waste of a reply to a question. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* I like your SNOOPY POSTER!! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php