It appears you have not yet registered with our community. To register please click here.

Origin XT RPG Network Home







XT Project Introduction
Blah blah intro to this place. To be composed later.

uploading and downloading, cant declare it


Aug 4 2006, 09:42 AM (Post #1)
Peasant

Posts: 22
Cash: 9,001 / 0
Group: Newbie
Joined: 7/30/06 05:17 PM
ok, now i want to make a new ACT= page and in there to put a upload script to upload files into the server.
now i have managed to make the upload it is actually uploads to the directory i set.
but when i try to download it, it wont download.

here is how i did it:

i added a new table to the database:

CODE
CREATE TABLE ibf_vip (
 id int(5) NOT NULL auto_increment,
 mid int(5) NOT NULL,
 mname text NOT NULL,
 title text NOT NULL,
 va text NOT NULL,
 creator text NOT NULL,
 file text NOT NULL,
 approve char(1) NOT NULL DEFAULT 'N',
 PRIMARY KEY (id)
)


after that once u upload a file it inserst the data as follows:

CODE
            $DB->query("INSERT INTO ibf_vip (mid, title, va, creator, file, approve, mname) VALUES ('{$ibforums->member['id']}','$dtitle','$desc','$dcreat','$arealname1','Y', '{$ibforums->member['name']}')");


mid = the user number who uploaded
title = title that the user submitted
va = file description
creator = file creator
file = the file name
approve = is it approved? yes or no
mname = the user name who uploaded



now it is all ok for now, the file is uploaded into the directory i set, in inserts all the data to the DB correctly .
but when i try to download it it, says i dont have accsess to the path.

this is how i made the download:

in a new ACT= page i made a DB query to select all the data from the ibf_vip table.

after that i made a link to each row that is in the table.
and the link goes like this:

http://www.domain.com/index.php?act=page&CODE=03&id=1

the CODE i used to build the download function is like this:


CODE
  // the download function
function do_download( ) {
 GLOBAL $print , $DB , $ibforums , $std;
// the input id
 $id = $ibforums->input['id'];

// select the data

 $DB->query( "SELECT * FROM ibf_vip WHERE id = {$id}" );

 // Does the download exists?
 if( $DB->get_num_rows(  ) == 0 ) {
   $this->error("no_download");
 }

 // Are the members of this group allowed to download files?

        $vadim = "4|9|10|11|12|13";
           $group_ids=array();$group_ids = explode("|",$vadim);
              if (in_array($ibforums->member['mgroup'], $group_ids)) {
  $row             = $DB->fetch_row( );

// the actuall url for the download

               $download         = $ibforums->vars['upload_memurl'].$row['file'];

// insert data to the download logs

       $ip = $ibforums->input['IP_ADDRESS'];
       $time = time();
         $DB->query("INSERT INTO ibf_vdownload_logs (name, title, ip, date) VALUES ('{$ibforums->member['name']}','{$row['title']}','$ip', '$time')");

// print the header
    header("Location: ".$download);
    print "<a href='".$download."'>{$ibforums->lang['click_redirect']}</a>";
}
 else
 {
// no accsess
                 $this->error("no_enter");
               }
}
}




i am always getting a "page cannot be found"

although i tryed to download it from a direct link to the file and it worked.

if u thinking that the file isnt in the data base or the FTP ur wrong i double chacked and it is there.



help would be appriciated.
Post Options

2 Pages < 1 2 
Aug 8 2006, 07:26 PM (Post #16)
Not Odd anymore
* * * * * * * * * *
Posts: 45,875
Cash: 1,915,578 / 1,817,041,051
Group: Administrator
Joined: 7/10/02 09:48 PM
No one will see the direct link as long as you use the first one ssmile.gif
Post Options

Aug 9 2006, 02:31 PM (Post #17)
Peasant

Posts: 22
Cash: 9,001 / 0
Group: Newbie
Joined: 7/30/06 05:17 PM
tnx alot man for the kind hel, really appriciated. ssmile.gif
Post Options

Aug 9 2006, 07:23 PM (Post #18)
Not Odd anymore
* * * * * * * * * *
Posts: 45,875
Cash: 1,915,578 / 1,817,041,051
Group: Administrator
Joined: 7/10/02 09:48 PM
It works? swink.gif
Post Options

2 Pages < 1 2