สอบถามเรื่อง multiple file downlaod หน่อยครับ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา สอบถามเรื่อง multiple file downlaod หน่อยครับ

สอบถามเรื่อง multiple file downlaod หน่อยครับ
สอบถามต่อหน่อยครับพี่นิก พอดี Test ในตัว localhost ใช้งานได้ แต่พอเอาขึ้นเว็บจริงกลับติดปัญหา

เวลาติีก Check Box แล้วกด download ไม่ได้ หน้ามันจะรีเฟสเฉยๆ ไม่มีไฟล์ลงมา ไม่ทราบว่าต้องตั้งค่าในส่วนไหนของ Server หรือป่าวครับ


Pusirinon 110.170.246.xxx 18-07-2016 17:11:37

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
  ต้องตรวจสอบที่โค้ดก่อนหรือป่าว ว่าคำสั่งไหนทำงาน อันไหนไม่ทำงาน


ninenik 122.155.42.xxx 18-07-2016
 ความคิดเห็นที่ 2
คือ Code ตัวเดียวกันผม Test ใน localhost มันใช้งานได้ แต่พอ up ขึ้น Serv จริง กลับใช้งานไม่ได้คับ

<?php
	$error = "";		//error holder
	if(isset($_POST['createpdf'])){
		$post = $_POST;		
		$file_folder = "files/";	// folder to load files
		if(extension_loaded('zip')){	// Checking ZIP extension is available
			if(isset($post['files']) and count($post['files']) > 0){	// Checking files are selected
				$zip = new ZipArchive();			// Load zip library	
				$zip_name = time().".zip";			// Zip name
				if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){		// Opening zip file to load files
					$error .=  "* Sorry ZIP creation failed at this time<br/>";
				}
				foreach($post['files'] as $file){				
					$zip->addFile($file_folder.$file);			// Adding files into zip
				}
				$zip->close();
				if(file_exists($zip_name)){
					// push to download the zip
					header('Content-type: application/zip');
					header('Content-Disposition: attachment; filename="'.$zip_name.'"');
					readfile($zip_name);
					// remove zip file is exists in temp path
					unlink($zip_name);
				}
				
			}else
				$error .= "* Please select file to zip <br/>";
		}else
			$error .= "* You dont have ZIP extension<br/>";
	}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Download As Zip</title>
</head>
<body>
<center><h1>Create Zip</h1></center>
<form name="zips" method="post">
<?php if(!empty($error)) { ?>
<p style=" border:#C10000 1px solid; background-color:#FFA8A8; color:#B00000;padding:8px; width:588px; margin:0 auto 10px;"><?php echo $error; ?></p>
<?php } ?>
<table width="600" border="1" align="center" cellpadding="10" cellspacing="0" style="border-collapse:collapse; border:#ccc 1px solid;">
  <tr>
    <td width="33" align="center">*</td>
    <td width="117" align="center">File Type</td>
    <td width="382">File Name</td>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" name="files[]" value="flowers.jpg" /></td>
    <td align="center"><img src="files/image.png" title="Image" width="16" height="16" /></td>
    <td>flowers.jpg</td>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" name="files[]" value="fun.jpg" /></td>
    <td align="center"><img src="files/image.png" title="Image" width="16" height="16" /></td>
    <td>fun.jpg</td>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" name="files[]" value="9lessons.docx" /></td>
    <td align="center"><img src="files/doc.png" title="Document" width="16" height="16" /></td>
    <td>9lessons.docx</td>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" name="files[]" value="9lessons.pdf" /></td>
    <td align="center"><img src="files/pdf.png" title="pdf" width="16" height="16" /></td>
    <td>9lessons.pdf</td>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" name="files[]" value="PEA2015-ACC-03.pdf" /></td>
    <td align="center"><img src="files/pdf.png" title="pdf" width="16" height="16" /></td>
    <td>PEA2015-ACC-03.pdf</td>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" name="files[]" value="PEA2015-ACC-04.pdf" /></td>
    <td align="center"><img src="files/pdf.png" title="pdf" width="16" height="16" /></td>
    <td>PEA2015-ACC-04.pdf</td>
  </tr>
  <tr>
    <td colspan="3" align="center">
    	<input type="submit" name="createpdf" style="border:0px; background-color:#800040; color:#FFF; padding:10px; cursor:pointer; font-weight:bold; border-radius:5px;" value="Download as ZIP" />&nbsp;
        <input type="reset" name="reset" style="border:0px; background-color:#D3D3D3; color:#000; font-weight:bold; padding:10px; cursor:pointer; border-radius:5px;" value="Reset" />
    </td>
    </tr>
</table>

</form>
</body>
</html>


pusirinon 58.8.200.xxx 18-07-2016 21:38
 ความคิดเห็นที่ 3
 ต้องตรวจสอบค่า error ว่าส่งค่าอะไรมา และก็ดูเรื่องโฟลเดอร์ที่เราจะเขียนไฟล์บน server
ด้วยว่าเป็น 777 หรือ 755 หรือไม่ เพื่อให้สามารถเขียนไฟล์ หรือลบไฟล์ ได้


ninenik 122.155.42.xxx 18-07-2016
 ความคิดเห็นที่ 4
ผมงงที่ว่ามันไม่ขึ้น error แต่มันแค่รีเฟสหน้าเฉยๆ ส่วนตัว Folder ผมได้ mod เป็น 777 แล้วคับพี่


pusirinon 115.87.246.xxx 19-07-2016 13:37
 ความคิดเห็นที่ 5
ตัวอย่างตามนี้เลยครับพี่

http://www.cap-a.com/multiple-file-download3/


pusirinon 115.87.246.xxx 19-07-2016 14:38
 ความคิดเห็นที่ 6
chrome ดาวน์โหลดได้ปกติ 


ninenik 122.155.42.xxx 19-07-2016
 ความคิดเห็นที่ 7
งั้นแสดงว่าน่าจะเป็นที่ host แล้วครับ เพราะผมลองเอาขึ้น host อีกเจ้านึงใช้งานได้ไม่มีปัญหา


pusirinon 115.87.246.xxx 19-07-2016 16:29
1






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ