Yeah, My chown reference was to chowning the folder that the files are uploaded to, not the indv. files.
Robert ----- Original Message ----- From: "JD Daniels" <[EMAIL PROTECTED]> To: "Todd Williamsen" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, February 05, 2002 12:21 PM Subject: RE: [PHP-DB] File Uploading... Two problems... > I believe when PHP saves a file, it is already owned by the web server user. > In my case, nouser. I could not get this behaviour to change. > > Normally you should not need to CHMOD or CHOWN anything you upload unless > you need them to be modified by ftp users as well. > Just make sure the folder is writeable by the web server user. (Preferably > not by anybody else... 777 is all bad :) > > If you do end up CHMODing: > On SCO, the CHMOD command did not behave like I expected it to... adding the > umask made it all good... ie, > > $rand_name=generate_filename("","jpg") > > file://Save The Uploaded File To Disk > @copy($image, > "/home/sites/madden.williamsen.net/web/recruiter/resumes/$rand_name") or > die("Couldn't Save File $image to $rand_name"); > > (Note beginning slash... Robert helped you there :) > > file://Give It Perms > umask(0); > chmod("/home/sites/madden.williamsen.net/web/recruiter/resumes/$temp_name",0 > 600); > (on my SCO box, 600 is the default perms anyway ) > > Here is my little funtion I use to generate file names: (It is not mine.. > but I cant remember who gave it to me :) > > function generate_filename ($len = 8,$ext) > { > $nps = ""; > mt_srand ((double) microtime() * 1000000); > > while (strlen($nps)<$len) > { > > $c = chr(mt_rand (0,255)); > > if (eregi("^[a-z0-9]$", $c)) $nps = $nps.$c; > > } > > $nps.=".$ext"; > return ($nps); > > } > > Of course, depending on what you are doing, completely random names may be > useless... I save them as temporary files to resize them and save them in a > DB with the regular name with special chars stripped out. > > JD > > > -----Original Message----- > From: Robert Weeks [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, February 05, 2002 7:19 AM > To: Todd Williamsen; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] File Uploading... Two problems... > > > On 2/5/02 9:58 AM, "Todd Williamsen" <[EMAIL PROTECTED]> wrote: > > Now I have two small issues... > > > > 1. How would I automate the file naming otherwise errors will fly (can't > > copy file... blah blah) > > You could replace the file name with a randomly generated number. There are > a number of ways to generate random numbers in PHP. Try this for starters: > > http://www.php.net/manual/en/function.mt-rand.php > > > 2. The second part is the most annoying. It seems that I cannot get the > > script to put the files into a directory I specify only where the script > > resides. I thought it was a permission issue, but the folder has been > chmod > > to 777 and it still won't do it... > > You need the path from root to the directory. Now you have: > > "home/sites/madden.williamsen.net/web/recruiter/resumes/$img1_name" > > You need a forward slash before home: > > "/home/sites/madden.williamsen.net/web/recruiter/resumes/$img1_name" > > Instead of using chmod 777 (ick!) you should change the ownership of the > file to be owned by the web server user which is usually "nobody" you can do > this with the chown command from the command line. > > Robert > > > > Directory structure > > > > home > > web > > recruiter < --- folder where the scripts reside > > resumes <-- the destination where I want the uploaded files to > > reside > > > > here is the code... > > > > <? > > > > // if $img_name isn't empty, try to copy the file > > if ($img1_name != "") { > > > > // copy the file to a directory or > > file://die and print an error message > > > > // NOTE! if you're on a Windows machine, > > // use Windows pathnames, like so: > > // copy("$img1", "C:\\some\\directory\\path\\$img1_name"); > > > > copy("$img1", > > "home/sites/madden.williamsen.net/web/recruiter/resumes/$img1_name") > > or die("Couldn't copy the file!"); > > > > } else { > > > > // if $img_name was empty, die and let us know why > > die("No input file specified"); > > > > } > > > > ?> > > > > thanks > > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php