Mime_content_type error saat dihosting

Message : Uncaught Error: Call to undefined function mime_content_type() in /home/ucteq9wi/public_html/admin/app/modules/filepicker/filepicker.php:216 Stack trace: #0 /home/ucteq9wi/public_html/admin/index.php(172): include() #1 {main} thrown

Agan agan untuk masalah Diatas mime_content_type error saat dihosting sedangkan pas dilocal bisa. Itu permasalahanya dimana dan solusinya gimana gan?

avatar Maulidi118
@Maulidi118

4 Kontribusi 0 Poin

Diperbarui 3 tahun yang lalu

4 Jawaban:

<div>Pastikan versi php antara local dan hosting itu sama ya gan</div>

avatar ahanafi
@ahanafi

815 Kontribusi 554 Poin

Dipost 3 tahun yang lalu

Tanggapan

Terima kasih gan solusinya akan saya coba dulu

<div>Masih belum bisa gan. Apakah ada eksistensi atau fungsi yang harus diaktifkan dalam cpanel hostingnya?</div>

avatar Maulidi118
@Maulidi118

4 Kontribusi 0 Poin

Dipost 3 tahun yang lalu

<div>coba dengan ini<br><br></div><pre>function mime_content_type($filename) { $result = new finfo();

if (is_resource($result) === true) {
    return $result-&amp;gt;file($filename, FILEINFO_MIME_TYPE);
}

return false;

}</pre><div><br>sumber : https://stackoverflow.com/questions/1263957/why-is-mime-content-type-deprecated-in-php</div>

avatar yukari06
@yukari06

137 Kontribusi 66 Poin

Dipost 3 tahun yang lalu

<div>untuk kodinganya seperti ini gan. kalau ada kesalahan atau penambahan kode. mohon koreksinya.</div><div><br></div><pre> case 'ajax-upload-file' :

	$path = $config[&#039;filepicker_upload_path&#039;];

	if ( !empty($_FILES) ) {
					
		if ( file_exists($path) &amp;amp;&amp;amp; is_dir($path) ) {
			
			if ( !is_writable($path) ) {
				$result = array (
					&#039;status&#039; =&amp;gt; &#039;error&#039;,
					&#039;message&#039;   =&amp;gt; &#039;Tidak dapat menulis file ke folder&#039;
				);
				
			} else {

				$new_name = upload_file($path, $_FILES[&#039;file&#039;]);
				if ($new_name) {
					
					$meta_file = [];
					
					$mime_image = [&#039;image/png&#039;, &#039;image/jpeg&#039;, &#039;image/bmp&#039;, &#039;image/gif&#039;];
					$current_mime_type = mime_content_type($path . $new_name);
					
					if (in_array($current_mime_type, $mime_image)) 
					{
						$img_size = @getimagesize($path . $new_name);
					
						$meta_file[&#039;default&#039;] = [&#039;width&#039; =&amp;gt; $img_size[0]
													, &#039;height&#039; =&amp;gt; $img_size[1]
													, &#039;size&#039; =&amp;gt; $_FILES[&#039;file&#039;][&#039;size&#039;]
												];

						foreach ($config[&#039;thumbnail&#039;] as $size =&amp;gt; $dim) 
						{
						
							if ($img_size[0] &amp;gt; $dim[&#039;w&#039;] || $img_size[1] &amp;gt; $dim[&#039;h&#039;]) 
							{
								$img_dim = image_dimension($path. $new_name, $dim[&#039;w&#039;], $dim[&#039;h&#039;]);
								$img_width = ceil($img_dim[0]);
								$img_height = ceil($img_dim[1]);
								
								$width = $height = null;
								if ($img_width &amp;gt;= $dim[&#039;w&#039;]) {
									
									$width = $dim[&#039;w&#039;];
									
								} else if ($img_height &amp;gt;= $dim[&#039;h&#039;]) {
									
									$height = $dim[&#039;h&#039;];
								}

								$layer = ImageWorkshop::initFromPath($path . $new_name);
								$layer-&amp;gt;resizeInPixel($width, $height, true);
								$name_path = pathinfo($new_name);
								$thumb_name = $name_path[&#039;filename&#039;] . &#039;_&#039; . $size . &#039;.&#039; . $name_path[&#039;extension&#039;];
								$layer-&amp;gt;save($path, $thumb_name, false, false, 97);
								
								$thumb_dim =  @getimagesize($path . $thumb_name);
								$meta_file[&#039;thumbnail&#039;][$size] = [
														&#039;filename&#039; =&amp;gt; $thumb_name
														, &#039;width&#039; =&amp;gt; $thumb_dim[0]
														, &#039;height&#039; =&amp;gt; $thumb_dim[1]
														, &#039;size&#039; =&amp;gt; @filesize($path . $thumb_name)
													];
							}
						}
					}
					
					$data_db[&#039;nama_file&#039;] = $new_name;
					$data_db[&#039;mime_type&#039;] = $current_mime_type;
					$data_db[&#039;size&#039;] = $_FILES[&#039;file&#039;][&#039;size&#039;];
					$data_db[&#039;tgl_upload&#039;] = date(&#039;Y-m-d H:i:s&#039;);
					$data_db[&#039;id_user_upload&#039;] = $_SESSION[&#039;user&#039;][&#039;id_user&#039;];
					$data_db[&#039;meta_file&#039;] = json_encode($meta_file);
					
					$sql = $db-&amp;gt;insert(&#039;file_picker&#039;, $data_db);
					
					$file_info = $data_db;
					$file_info[&#039;bulan_upload&#039;][date(&#039;Y-m&#039;)] = $nama_bulan[date(&#039;n&#039;)] . &#039; &#039; . date(&#039;Y&#039;);
					$file_info[&#039;id_file_picker&#039;] = $db-&amp;gt;lastInsertId();
					$result = get_file_properties($current_mime_type, $new_name, $meta_file);
					$file_info = array_merge($file_info, $result);
					
					$result = [
							&#039;status&#039;    =&amp;gt; &#039;success&#039;,
							&#039;message&#039;      =&amp;gt; &#039;File berhasil diupload.&#039;,
							&#039;file_info&#039; =&amp;gt; $file_info
					];
				} else {
					$result = [
						&#039;status&#039; =&amp;gt; &#039;error&#039;,
						&#039;message&#039;   =&amp;gt; &#039;System error&#039;
					];
				}
			}

		} else {
			$result = [
				&#039;status&#039; =&amp;gt; &#039;error&#039;,
				&#039;message&#039;   =&amp;gt; &#039;Folder &#039; . $path . &#039; tidak ditemukan&#039;
			];
		}
		
		

		// Return the response
		echo json_encode($result);
		exit;
	}&lt;/pre&gt;
avatar Maulidi118
@Maulidi118

4 Kontribusi 0 Poin

Dipost 3 tahun yang lalu

Tanggapan

coba script jawabanku di taruh di atas if ( !empty($_FILES) ) { ,,, kalo masi error,, errornya berubah atau tidak,,,

Masih error gan

iyaa,,, errornya masi sama atau berubah ?

Errornya mlaha di koding fungsi tersebut gan

Login untuk ikut Jawaban