Post by mondy » Mon Aug 09, 2010 10:35 pm

b"h

I made an improvement in my download system, instead of download each file, i change the code so i can download files with FTP and then asign them as download files.
I have seen it in UBERCART under DRUPEL system, but there this is much more better.

admin/controller/download.php - function insert() - about line 36

Code: Select all

/*		comment this 
	        if (is_uploaded_file($this->request->files['download']['tmp_name'])) {
							$filename = $this->request->files['download']['name'] . '.' . md5(rand());
				
				move_uploaded_file($this->request->files['download']['tmp_name'], DIR_DOWNLOAD . $filename);

				if (file_exists(DIR_DOWNLOAD . $filename)) {
					$data['download'] = $filename;
					$data['mask'] = $this->request->files['download']['name'];
				}
			}
*/                   
                       // use this lines
			if ($this->request->post['fileName']) {
					$filename = $this->request->post['fileName'] . '.' . md5(rand());
				rename(DIR_DOWNLOAD.$this->request->post['fileName'], DIR_DOWNLOAD . $filename);

				if (file_exists(DIR_DOWNLOAD . $filename)) {
					$data['download'] = $filename;
					$data['mask'] = $this->request->post['fileName'];
				}
			}
function getForm() - about line 320

Code: Select all

		// add this line
     $this->data['files'] = scandir(DIR_DOWNLOAD);
admin/view/template/catalog/download_form.php - about line 35

Code: Select all

        <tr>
		<td>First, download files to download directory.</td>
		<td>
		<select name="fileName">
		<?php foreach ($files as $file) { ?>
		<option value="<?php echo $file ?>"><?php echo $file ?></option>
		<?php } ?>
		</select>
		</td>
		<?php ?>
	    </tr>
enjoy,
Mo.

New member

Posts

Joined
Tue Nov 11, 2008 8:01 am
Who is online

Users browsing this forum: No registered users and 98 guests