10/10/2018, 11:14
[Help] Code upload ảnh bằng ajax!
Bác nào biết làm một code upload ảnh bẳng ajax giống upanh.com ko ạ? hoặc code up ảnh mà chọn nhiều file cùng lúc cũng đc ạ..Nếu có share dùm mình với!
Bài liên quan





www.swfupload.org
http://www.uploadify.com/ tự đọc doc nha bác
Chỉnh sửa thư mục upload thì ở file nào ạ
Với swfupload trong file index.php của demo sẽ nhìn thấy dòng ở phần header cấu hình javascript như sau:
<script type="text/javascript"> var swfu; window.onload = function() { var settings = { flash_url : "../swfupload/swfupload.swf", //cấu hình đường dẫn file swf upload_url: "upload.php", //file xử lý upload ở đây, sửa kích thước cũng ở đây. Xử lý tất... post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"}, file_size_limit : "100 MB", //giới hạn size file_types : "*.*", //cho phép loại file nào file_types_description : "All Files", file_upload_limit : 100, //giới hạn bao nhiêu file upload cùng 1 lúc file_queue_limit : 0, custom_settings : { progressTarget : "fsUploadProgress", cancelButtonId : "btnCancel" }, debug: true, //button settings button_image_url: "images/TestImageNoText_65x29.png", button_width: "65", button_height: "29", button_placeholder_id: "spanButtonPlaceHolder", button_text: '<span class="theFont">Hello</span>', button_text_style: ".theFont { font-size: 16; }", button_text_left_padding: 12, button_text_top_padding: 3, // The event handler functions are defined in handlers.js //gọi hàm trong file handlers.js đối với các sự kiện file_queued_handler : fileQueued, file_queue_error_handler : fileQueueError, upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess //... </script>upload.php
<?php if (isset($_POST["PHPSESSID"])) { session_id($_POST["PHPSESSID"]); } session_start(); // The Demos don't save files // In this demo we trigger the uploadError event in SWFUpload by returning a status code other than 200 (which is the default returned by PHP) if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) { // Usually we'll only get an invalid upload if our PHP.INI upload sizes are smaller than the size of the file we allowed // to be uploaded. header("HTTP/1.1 500 File Upload Error"); if (isset($_FILES["Filedata"])) { echo $_FILES["Filedata"]["error"]; } exit(0); } echo "Make sure Flash Player on OS X works"; ?>Ví dụ: Bây giờ 03/12/2010 sau khi upload là... 2010/12/03/file vừa up
Xem trang demo
http://mega1080.cz.cc/