admin.php

 <tr>
      <td><?php echo MOD_DS_PRODFILE;?>: <?php echo required();?></td>
      <td><input name="filename" type="file" size="40" class="fileinput mask" />
        <span style="margin-left:80px"><?php echo tooltip(MOD_DS_PRODFILE_T);?></span></td>
    </tr>

        <tr>
      <td><?php echo MOD_DS_PRODFILE;?>: <?php echo required();?></td>
      <td><input name="filename" type="file" size="40" class="fileinput mask" />
        <span style="margin-left:80px"><?php echo tooltip(MOD_DS_PRODFILE_T);?></span></td>
    </tr>

admin_class.php

       */
      public function getPaidDownload($token)
      {
          global $db, $core;

          $id = sanitize($token);
          $id = $db->escape($token);

          $row = $db->first("SELECT t.*, p.filename" 
          . " \n FROM " . $this->trTable . " as t" 
          . " \n LEFT JOIN " . $this->mTable . " as p ON t.pid = p.id" 
          . " \n WHERE t.token = '" . $db->escape($id) . "'" 
          . " \n AND t.status = '1' AND t.active = '1'" 
          . " \n AND p.active = '1'");

          return ($row) ? $row : 0;
      }

      /**


              if (!empty($_FILES['filename']['name'])) {
              if (!preg_match("/(\.zip|\.rar)$/i", $_FILES['filename']['name']))
                  $core->msgs['filename'] = MOD_AM_FILE_ATT_R;
          }

                      // Procces File
              $file = getValue("filename",$this->mTable,"id = '".$this->digiid."'");
              if (!empty($_FILES['filename']['name'])) {
                  $newName = "FILE_" . randName();
                  $ext = substr($_FILES['filename']['name'], strrpos($_FILES['filename']['name'], '.') + 1);
                  $fullname = $this->filedir . $newName.".".strtolower($ext);                 

                  if ($file)
                      @unlink($this->filedir . $file);
                  $res = move_uploaded_file($_FILES['filename']['tmp_name'], $fullname);
                  $data['filename'] = $newName.".".strtolower($ext);
                  $data['filesize'] = filesize($fullname);  
              } else {
                  $data['filename'] = $file;
              }


              ($this->digiid) ? $db->update($this->mTable, $data, "id='" . (int)$this->digiid . "'") : $db->insert($this->mTable, $data);
              $message = ($this->digiid) ? MOD_DS_PRODUPDATED : MOD_DS_PRODADDED;

              ($db->affected()) ? $wojosec->writeLog($message, "", "no", "module") . $core->msgOk($message) : $core->msgAlert(_SYSTEM_PROCCESS);

          } else
              print $core->msgStatus();
      }

download.php

 // Free Downloads
  if (isset($_GET['free'])) {
      $row = $android->getFreeDownload($_GET['free']);

      if ($row) {
          $fname = basename($row['filename']);
          $file_path = '';
          $android->fetchFile(BASE_DIR, $fname, $file_path);

          $fsize = filesize($file_path);
          $fext = strtolower(substr(strrchr($fname, "."), 1));

          if (!file_exists($file_path) || !is_file($file_path)) {
              redirect_to(($core->seo == 1) ? $core->site_url . '/content/android/?msg=1' : $core->site_url . '/modules.php?module=android&msg=1');
              die();
          }

          if (!array_key_exists($fext, $allowed_ext)) {
              redirect_to(($core->seo == 1) ? $core->site_url . '/content/android/?msg=1' : $core->site_url . '/modules.php?module=android&msg=2');
              die();
          }

          if ($android->allow_free == 'n' && !$user->logged_in) {
              redirect_to(($core->seo == 1) ? $core->site_url . '/content/android/?msg=1' : $core->site_url . '/modules.php?module=android&msg=3');
              die();
          }

          if ($allowed_ext[$fext] == '') {
              $mtype = '';
              if (function_exists('mime_content_type')) {
                  $mtype = mime_content_type($file_path);
              } elseif (function_exists('finfo_file')) {
                  $finfo = finfo_open(FILEINFO_MIME);
                  $mtype = finfo_file($finfo, $file_path);
                  finfo_close($finfo);
              }
              if ($mtype == '') {
                  $mtype = "application/force-download";
              }
          } else {
              $mtype = $allowed_ext[$fext];
          }

How to convert upload path to insert url path? Thanks all.

Recommended Answers

All 7 Replies

Help me !, please

Just looking problem statement and code, no body can guess what you trying to do. Describe your problem precisely

I want to change file upload by insert path url download in website

If you open your class files, some where you will find class member filedir (see line 32 and 35 in your code).
So there you can change upload path and save that class file.

commented: "filedir" change name? to insert url part in web. Thanks bro. +0

"filedir" change name? to insert url part in web
Thanks bro.

Yes you can change value of filedir as you wanted now in your class defiinition file

replace "filedir" to "urldir" ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.