Get ready for BLACK FRIDAY shopping starting in

Forums

PHP

This topic is locked

Can someone add a CHMOD to this script!

Posted 08 Aug 2007 12:39:35
1
has voted
08 Aug 2007 12:39:35 Matthew Reid posted:
<font face='Verdana'>Hi, can someone please add the php's CHMOD code to this script so that my users can add profile images and will automatically change the permissions to 777?

&lt;?php
//This function separates the extension from the rest of the file name and returns it
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}

//This applies the function to our file
$ext = findexts ($_FILES['uploaded']['name']) ;

//This line assigns a random number to a variable. You could also use a timestamp here if you prefer.
$ran = "$MM_Username" ;

//This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended.
$ran2 = $ran.".";

//This assigns the subdirectory you want to save into... make sure it exists!
$target = "userimages/user/";

//This combines the directory, the random file name, and the extension
$target = $target . $ran2.$ext;

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The profile image is uploaded ".$ran2.$ext;
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
?&gt;

</font id='Verdana'><font color=red></font id=red>

Reply to this topic