我将变量从按钮传递到 myFunction。我可以创建一个显示正确信息的警报框,但是当我在复制命令中使用这些变量时,它什么也不做。我的目标是在目录中显示图像。用户可以单击包含该图像的按钮,然后将图像文件从 /storage/ 目录复制到 /attach/ 目录。任何人都可以帮我解决这个问题....谢谢
我创建的完整文件是:
<!DOCTYPE html>
<html>
<head>
<title>Mark Nutt</title>
<script>
function myFunction(greeting,greeting2,source,destination)
{
<?php
echo copy('"+source+"','"+destination+"');
?>
alert("copy('"+source+"','"+destination+"')");
alert(greeting2 +' attached to email!');
}
</script>
</head>
<body>
<a href="#" onclick="MyWindow=window.open('http://www.davidsdomaindesign.com/marknutt/emails/emails.php','_self'); return true;"><font size="2" color="white"><input type="button" value="I'm Done" /></font></a><br />
<?php
$files = glob("/home/davidsdo/public_html/marknutt/photos/storage/*.jpg");
asort($files);
for ($i=0; $i<count($files); $i++)
{$num = $files[$i];
$file = substr($num,51);
?>
<button onclick="myFunction('<?php echo $file ?>','<?php echo substr_replace($file,"",-4); ?>','<?php echo $source='/home/davidsdo/public_html/marknutt/photos/storage/'; echo $file; ?>','<?php echo $destination='/home/davidsdo/public_html/marknutt/emails/attach/'; echo $file; ?>')" >
<input type="button" value="<?php echo substr_replace($file,"",-4); ?>" /><br /><img src="http://www.davidsdomaindesign.com/marknutt/photos/storage/<?php echo $file ?>" alt="<?php echo $file ?>" width="125" height="125">
</button>
<?php
}
?>
</body>
</html>