我想要做和实现的是:
- 我想在用户注册期间上传图片。假设,我有一个接受输入作为名称和输入文件上传(上传按钮)和保存按钮的表单。
上传.php
$targetFolder = 'uploads';
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
Javascript
jQuery('#file_upload').uploadify({
'swf' : plug+'/uploadify-v3.1/uploadify.swf',
'uploader' : plug + '/uploadify-v3.1/uploadify.php'
// Put your options here
});
我将如何做到这一点?