Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Can not upload .apk file in CodeIgniter

Posted on 2011-09-19
12
1,957 Views
Last Modified: 2012-05-12
Hello,

I am working on application that upload some kind of file from PC to the server. I am using Codeigniter PHP frame work. The kind of files are either images (gif, jppg, png) and Android application package file (.apk). With images file the code work fine but when I am trying to upload .apk it give me:

The filetype you are attempting to upload is not allowed.

I added this line in the mime.php file in the Codeigniter config:
'apk' => 'application/vnd.android.package-archive'

Open in new window


What is missing or I have to do ??
0
Comment
Question by:Ahmed Merghani
  • 6
  • 4
  • 2
12 Comments
 
LVL 4

Expert Comment

by:h4hardy
ID: 36565207
Hi fishboy,

you can try with the below code,

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|apk';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';

$this->load->library('upload', $config);

// Alternately you can set preferences by calling the initialize function. Useful if you auto-load the class:
$this->upload->initialize($config);

Open in new window

0
 
LVL 7

Accepted Solution

by:
boon86 earned 500 total points
ID: 36565215
hi,

you probably need to add the mime type to mimes.php and to config files. Please read:

http://codeigniter.com/user_guide/libraries/file_uploading.html
and
http://codeigniter.com/forums/viewthread/145893/

hope that help.
0
 
LVL 8

Author Comment

by:Ahmed Merghani
ID: 36565819
Thanks all for reply.
h4hardy, I forget to mention that I already apply your code.
boon86, I will go throw the links and feedback.

regards
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
LVL 4

Expert Comment

by:h4hardy
ID: 36565847
hi fishboy,

so is that not working?
0
 
LVL 8

Author Comment

by:Ahmed Merghani
ID: 36565988
yes did not work and give me this as I mentioned:

The filetype you are attempting to upload is not allowed.

Open in new window

0
 
LVL 7

Expert Comment

by:boon86
ID: 36566054
try add: inside this: system/application/config/mimes.php

'apk'    =>    array('application/vnd.android.package-archive', 'application/x-download', 'application/unknown'),

if not work try:
'apk'    =>    array('application/vnd.android.package-archive', 'application/x-download', 'application/force-download'),


also inside your .htaccess:

AddType application/vnd.android.package-archive apk


hope that help
0
 
LVL 8

Author Comment

by:Ahmed Merghani
ID: 36566538
Thanks boon86 for response I tried the first and second code but give the same error.

regarding the .htaccess file, where I can find it?

NOTE: I am using CodIgniter version 2.0.3.
0
 
LVL 7

Expert Comment

by:boon86
ID: 36566685
.htaccess can be found on directory of:

/public_html/
/htdocs/
/httpdocs/
/www/

depend on your server setting.
0
 
LVL 8

Author Comment

by:Ahmed Merghani
ID: 36568425
I am using WAMP on window XP. I did not found the file in any one of the suggested directory.

But in CodeIgniter I found it in the application directory and this is the content:
Deny from all

Open in new window


I try to add/replace with "AddType application/vnd.android.package-archive apk" but still the same result.
0
 
LVL 7

Expert Comment

by:boon86
ID: 36571546
i forget the . symbol:

try add this inside .htaccess where your project working on:
AddType application/vnd.android.package-archive .apk

Open in new window

0
 
LVL 8

Author Comment

by:Ahmed Merghani
ID: 36571810
boon86, yes I tried this but the same.

Any one can help?
0
 
LVL 8

Author Comment

by:Ahmed Merghani
ID: 36572064
Hi boon86,

Your comments and above links specially the second one lead me to the solution.

Find the mimes.php. For CodeIgniter version 2.x, it will be inside:
application/config/

And for previous version, it will be inside:
system/application/config/

Add this line:
'apk' => 'application/octet-stream'

Open in new window


This work fine but I advice to add this line:
'apk' => array('application/vnd.android.package-archive', 'application/octet-stream')

Open in new window


Thanks all for help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Wordpress French and English Site 6 77
AWK: Am I duplicating the comma delimiter in this code? 5 25
Apache LDAP Authentication 20 30
if (is_singular not working 5 18
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question