0
在http://www.finalwebsites.com/snippets.php?id=7(查看代碼爲類http://pastebin.com/sqbMw4sR)PHP類上傳我想利用現有的PHP類上傳文件的文件
而且我在上傳處理文件,以下代碼
$max_size = 1024*100; // the max. size for uploading
$my_upload = new file_upload;
// upload directory
$my_upload->upload_dir = HOME_PATH."users/";
// allowed extensions
$my_upload->extensions = array(".png", ".jpeg", ".jpg", ".gif");
$my_upload->max_length_filename = 50;
$my_upload->rename_file = true;
$new_name = "testing" . time();
if(isset($Submit)) {
$my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
$my_upload->the_file = $_FILES['upload']['name'];
$my_upload->http_error = $_FILES['upload']['error'];
$my_upload->the_mime_type = $_FILES['upload']['type'];
// because only a checked checkboxes is true
$r = $_POST['replace'];
$my_upload->replace = (isset($r)) ? $r : "n";
// use this boolean to check for a valid filename
$a = $_POST['check'];
$my_upload->do_filename_check = (isset($a)) ? $a : "n";
if ($my_upload->upload($new_name)) {
// new name is an additional filename information,
//use this to rename the uploaded file
$full_path = $my_upload->upload_dir.$my_upload->file_copy;
// just some information about the uploaded file
$info = $my_upload->get_uploaded_file_info($full_path);
// ... or do something like insert the filename to the database
}
}
$error = $my_upload->show_error_string();
據筆者瞭解,該文件應該已經上傳的,但它沒有拋出任何錯誤,也沒有被上傳。
我打電話使用給ajaxForm這個文件(jQuery插件http://malsup.com/jquery/form/#file-upload)。
任何人都可以請指出這裏有什麼問題?
您正在發佈的數據,在本課程中正在接收,請在您的ajaxForm()函數中使用alert檢查 – 2012-02-02 08:05:14
我不知道該怎麼做?在開發者的Web控制檯,我可以看到,雖然正在作出的XHR呼叫。 – ptamzz 2012-02-02 08:10:11