Welcome Guest, Not a member yet? Register   Sign In
how to upload file using password
#1

[eluser]RaiNnTeaRs[/eluser]
Hi all,There are some sites,that required password to upload files. can someone give me code to upload files using authentication ?
$cek = $this->session->userdata('logged_in');
if ($cek != 'yes')
{
echo "Please Sign in first ^^";
$this->login();
}
else
{
$pv=$this->session->userdata('level');
if ($pv==100)
{

$config['upload_path'] '/storage/';
$config['allowed_types'] = 'gif|jpg|png|zip|rar|txt';
$config['max_size'] = '20000';
$config['max_width'] = '1024';
$config['max_height'] = '768';

$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array ('error' => $this->upload->display_errors()
);
$this->load->view('upload_form',$error);
}
else
{
$data= array ('upload_data' => $this->upload->data()

);
$data['descrip']=$_POST['descrip'];
$this->load->view('upload_success',$data);
}

}
else
{
ECHO "SORRY , your cannot upload any files due to you level privilledge";
}
}
}
NB : THIS CODE ONLY WORK FOR MY LOCALHOST;PLEASE SEND ME A CODE FOR SOME SITES THAT REQUIRE PASSWORD AUTHENTICATION.
#2

[eluser]nirbhab[/eluser]
Dear,

In any project:
There are different level of user privileges.
All can perform different tasks.
so authentication and authorization module must be different from the type of tasks performed by user.

In your context.
you are asking for authentication class and as well as upload module.

Perform both the task differently and provide, authentication logic on the upload function.
Sorry, for not studying your code. But if are likely to do the same.
Than debug your code. and ask for some code error, rather than the whole.

As you said that code is working on local, but did you tested on live domain.
if yes, perform changes in current code, if not working.
if not, test it.

Have a gr8 day ahead.
#3

[eluser]Grahack[/eluser]
There are plenty of auth modules that have ben developped by the community. Try them all and choose one. Good luck!
#4

[eluser]RaiNnTeaRs[/eluser]
Thanks for all the comment.But I only need the authentication code for uploading file , just like in FTP Client ( like FileZilla,etc).I need this code badly.Thanks.
#5

[eluser]Hermawan Haryanto[/eluser]
I'm not sure people here is willing to give out the code or anything else without you even trying.
Why don't you try it yourself and give us what you have, so we can make adjustment and modification.

Good luck,
Hermawan Haryanto
#6

[eluser]nirbhab[/eluser]
if i am not wrong, you are talking about file uploads through FTP,
Use FTP class of CI. Or any PHP FTP class.

Glad to know, what you are exactly talking about :-)
#7

[eluser]RaiNnTeaRs[/eluser]
lol,sorry for my bad english Big Grin
and thanks for your help.
Btw, what is the difference between using the ftp class and upload class ?
Sorry for my foolishness,but I want to learn more about this CodeIgniter ^^
#8

[eluser]Pascal Kriete[/eluser]
FTP is much less restricted than an upload form. With ftp you can move, upload, download, and delete files. This is a level of access that you don't want your users to have. Uploads, on the other hand, can be very restricted (for example: only jpg's smaller than 80x80 pixels).

To secure an upload you protect the controller with an authentication library (there are literally hundreds of them on these forums). That means noone has access to the upload form unless they know the password.
#9

[eluser]RaiNnTeaRs[/eluser]
ow i c, but why my upload class is not working ? should i use the old fashioned PHP way ? function copy() or die ?
The error message is upload path is not valid...
my upload path should be CI activedirectory\storage
#10

[eluser]Pascal Kriete[/eluser]
What did you put in your config array? Does php have write access to the directory? Is the path correct?

Code:
$config['upload_path'] = './activedirectory/storage';




Theme © iAndrew 2016 - Forum software by © MyBB