我正在尝试一些 php/mysql 资源,并坚持使用 MAMP 将图像上传到永久文件夹。这是表格:
<form action="create_user.php" method="post" enctype="multipart/form-data">
<fieldset>
<label for="first_name">First Name:</label>
<input type="text" name="first_name" size="20" /><br />
<label for="last_name">Last Name:</label>
<input type="text" name="last_name" size="20" /><br />
<label for="email">E-mail address:</label>
<input type="text" name="email" size="50" /><br />
<label for="facebook_url">Facebook URL:</label>
<input type="text" name="facebook_url" size="50" /><br />
<label for="twitter_handle">Twitter Handle:</label>
<input type="text" name="twitter_handle" size="20" /><br />
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<label for="user_pic">Upload a picture:</label>
<input type="file" name="user_pic" size="30" /><br />
<label for="bio">Bio:</label>
<textarea name="bio" cols="40" rows="10"/></textarea>
</fieldset>
<br />
这是我的脚本中与表单交互的代码:
$upload_dir = SITE_ROOT . "missmanphpmysql/uploads/profile_pics/";
$image_fieldname = "user_pic";
这是检查权限等的函数和自定义函数:
@move_uploaded_file($_FILES[$image_fieldname]['tmp_name'], $upload_filename)
or handle_error("we had a problem saving your image to " .
"its permanent location.",
"permissions or related error moving " .
"file to {$upload_filename}");
我得到的只是上面的错误信息。我试图更改 finder 和 chmod 中的权限,但我可能做错了。非常感谢任何帮助。