Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-18-2008, 04:51 PM   PM User | #1
PRodgers4284
Regular Coder

 
Join Date: Jan 2008
Posts: 216
Thanks: 10
Thanked 1 Time in 1 Post
PRodgers4284 has a little shameless behaviour in the past
Download link not working

I am having trouble with a download link, it doesnt same to be working but i can see the file the bottom left of the screen once i click it but it doesnt same to download the file. I have the file uploading to a file on the server and the file goes into the database fine but it doesnt same to open the document when i click on the link, can anyone help please

My code for the upload file is

PHP Code:
$uploadDir 'C:/wamp/www/upload/';

if (isset(
$_POST['submit']) && $error_stat == 0) {

    
$fileName $_FILES['userfile']['name'];
    
$tmpName  $_FILES['userfile']['tmp_name'];
    
$fileSize $_FILES['userfile']['size'];
    
$fileType $_FILES['userfile']['type'];

    
// the files will be saved in filePath 
    
$filePath $uploadDir $fileName;

    
// move the files to the specified directory
    // if the upload directory is not writable or
    // something else went wrong $result will be false
    
$result    move_uploaded_file($tmpName$filePath);
    if (!
$result) {
        echo 
"Error uploading file";
        exit;
    }

    include(
"database.php");

    if(!
get_magic_quotes_gpc())
    {
        
$fileName  addslashes($fileName);
        
$filePath  addslashes($filePath);
    }  
    
    
 
     
mysql_query("UPDATE users SET username='" $_POST["username"] . "',jobcatergory='" $_POST["jobcatergory"] . "',recentjob='" $_POST["recentjob"] . "',employmenttype='" $_POST["employmenttype"] . "',careerlevel='" $_POST["careerlevel"] . "',educationallevel='" $_POST["educationallevel"] . "',skills='" $_POST["skills"] . "', name='$fileName', type='$fileType', size='$fileSize', path='$filePath' WHERE username='" $_SESSION["username"] . "'");  
?> 
And the download link to the file is:

PHP Code:
<?php echo '<a href="'.$account['path'].'">Download File</a>'; ?
PRodgers4284 is offline   Reply With Quote
Old 02-19-2008, 01:47 AM   PM User | #2
Ultragames
Regular Coder

 
Join Date: Aug 2002
Location: Oregon, United States of America
Posts: 882
Thanks: 1
Thanked 9 Times in 9 Posts
Ultragames has a little shameless behaviour in the past
I don't have an answer to your question, but I can't pass by this thread with out pointing a few things out:

Do not use magic quotes! It's good that your checking for it, but I strongly suggest having it turned off. It has even been removed from PHP 6 because of issues related to it.

Escape any data that goes into a database! SQL injection can cripple a site, or worse yet, let a hacker sneak in quietly. Along with normal data verification, you should always use mysql_real_escape_string() on any variables going into a query. INSERT, UPDATE, REPLACE, DELETE, and SELECT. Always assume that no query is safe.
__________________
If I'm postin here, I NEED YOUR HELP!!
Ultragames is offline   Reply With Quote
Old 02-19-2008, 01:45 PM   PM User | #3
PRodgers4284
Regular Coder

 
Join Date: Jan 2008
Posts: 216
Thanks: 10
Thanked 1 Time in 1 Post
PRodgers4284 has a little shameless behaviour in the past
Quote:
Originally Posted by Ultragames View Post
I don't have an answer to your question, but I can't pass by this thread with out pointing a few things out:

Do not use magic quotes! It's good that your checking for it, but I strongly suggest having it turned off. It has even been removed from PHP 6 because of issues related to it.

Escape any data that goes into a database! SQL injection can cripple a site, or worse yet, let a hacker sneak in quietly. Along with normal data verification, you should always use mysql_real_escape_string() on any variables going into a query. INSERT, UPDATE, REPLACE, DELETE, and SELECT. Always assume that no query is safe.
Thanks for the reply, appreciate your advise, you have mentioned the magic quotes and i was wondering how to turn these off?
PRodgers4284 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:15 AM.


Advertisement
Log in to turn off these ads.