Hi all!
I’ve been experimenting with php, xml and as and some of it is quite new to me and I need a little help with a bit of code.
I’ve written a bit of code that creates folders and copy files. It works, but I want it only to work when I click submit from a form and I think to get it to work I have to either put it in a function or if statement.
PHP:
$mypath='slides/'.time();
$mypath2='slides/'.time().'/imgs';
$mypath3='slides/'.time().'/images';
$mypath4='slides/'.time().'/images/thumbs';
mkdir($mypath, 0777,true);
mkdir($mypath2, 0777, true);
mkdir($mypath3, 0777, true);
mkdir($mypath4, 0777, true);
//$user_name =$row_user['username']; ;
//chown($mypath, $user_name);
$file1 = 'templates/gallery.swf';
$file2 = 'templates/images.xml';
$file3 = 'templates/index.html';
$file4 = 'templates/AC_RunActiveContent.js';
$file5 = 'templates/imageForm+xml.php';
$file6 = 'templates/css.css';
//$file7 = 'templates/imgs';
$file8 = 'imgs/accept_icon.gif';
$file9 = 'imgs/error_icon.gif';
$file10 = 'imgs/img_icon.gif';
$file11 = 'imgs/warn_icon.gif';
$file12 = 'imgs/write_icon.gif';
$file13 = 'imgs/header2.gif';
$file14 = 'imgs/header.gif';
$newfile1 = $mypath.'/gallery.swf';
$newfile2 = $mypath.'/images.xml';
$newfile3 = $mypath.'/index.html';
$newfile4 = $mypath.'/AC_RunActiveContent.js';
$newfile5 = $mypath.'/imageForm+xml.php';
$newfile6 = $mypath.'/css.css';
//$newfile7 = $mypath.'/imgs';
$newfile8 = $mypath2.'/accept_icon.gif';
$newfile9 = $mypath2.'/error_icon.gif';
$newfile10 = $mypath2.'/img_icon.gif';
$newfile11 = $mypath2.'/warn_icon.gif';
$newfile12 = $mypath2.'/write_icon.gif';
$newfile13 = $mypath2.'/header2.gif';
$newfile14 = $mypath2.'/header.gif';
/*chmod($mypath, 777);
chmod($mypath.'/gallery.swf', 777);
chmod($mypath.'/images.xml', 777);
chmod($mypath.'/index.html', 777);
chmod($mypath.'/AC_RunActiveContent.js', 777);
chmod($mypath.'/imageForm+xml.php', 777);
chmod($mypath.'/css.css', 777);
chmod($mypath.'/imgs/accept_icon.gif', 777);
chmod($mypath.'/imgs/error_icon.gif', 777);
chmod($mypath.'/imgs/img_icon.gif', 777);
chmod($mypath.'/imgs/warn_icon.gif', 777);
chmod($mypath.'/imgs/write_icon.gif', 777);
chmod($mypath.'/imgs/header2.gif', 777);
chmod($mypath.'/imgs/header.gif', 777);
*/
if (!copy($file1, $newfile1))
{
echo "failed to copy $file1...
";
}
if (!copy($file2, $newfile2))
{
echo "failed to copy $file2...
";
}
if (!copy($file3, $newfile3))
{
echo "failed to copy $file3...
";
}
if (!copy($file4, $newfile4))
{
echo "failed to copy $file4...
";
}
if (!copy($file5, $newfile5))
{
echo "failed to copy $file5...
";
}
if (!copy($file6, $newfile6))
{
echo "failed to copy $file6...
";
}
/*if (!copy($file7, $newfile7))
{
echo "failed to copy $file7...
";
}*/
if (!copy($file8, $newfile8))
{
echo "failed to copy $file7...
";
}
if (!copy($file9, $newfile9))
{
echo "failed to copy $file10...
";
}
if (!copy($file10, $newfile10))
{
echo "failed to copy $file10...
";
}
if (!copy($file11, $newfile11))
{
echo "failed to copy $file11...
";
}
if (!copy($file12, $newfile12))
{
echo "failed to copy $file12...
";
}
if (!copy($file13, $newfile13))
{
echo "failed to copy $file13...
";
}
if (!copy($file14, $newfile14))
{
echo "failed to copy $file14...
";
}
//}
?>
HTML Form:
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="slideshowCreator">
<label>Name of Slide Show:</label><input name="name" type="text" value="" /><br /><div id="input_help">Make sure that this name is unique!"</div>
<label>Description of Slide Show:</label><textarea name="des" cols="26" rows="10" wrap="virtual"></textarea>
<br />
<input name="path" type="hidden" value="<? echo $mypath ?>" />
<input name="url2" type="hidden" value="<? echo $newfile5 ?>" />
<label></label><input name="Submit" type="submit" value="Submit">
<input type="hidden" name="MM_insert" value="slideshowCreator" />
</form>
I know it’s probably something simple, but I just can’t figure it out at the moment, i’m a little new to php to a certain degree…especially in mkdir and rmdir.
I will be very grateful if someone could help me with this