General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 28th, 2002, 07:59 PM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
File Download Link Not Working!

Hello once again one and all,

Well Ive got the main part of my scripts sorted now. I will explain what I have done.

Online Lecture Video Downloads

1. The user can use a form to enter details about lectures. The user can browse for a video file of the lecture to upload to the server.
2. The data is sent to mysql where it is stored.
3. The file is uploaded to a directory that I have set aside for such uploads (mysql stores the filePath in a field).
4. When students log onto the site, they are presented with a table including each lectures data, such as module code, title, week number, topics covered. There is also a link to download the file in the table.

This is where I have a small problem. When a link is clicked that points to a file, the file will not download on my client pc; although it will open on \\localhost. Note I say ‘open’ not download(it opens the file in the application it is related to. Ie a realvideo file opens in real player, windows media file opens in media player. Etc)

It is quite a big problem actually!

Hear is the code anyway – if you can spot my problem I would be glad to hear from you. I have attatched the set of scripts and the database file if you wanna check out the whole thing (2 scripts, 1 form and database folder).
I have included a small readme file as well to show you how to run it – very simple!
Attached Files
File Type: zip myscripts.zip (4.9 KB, 597 views)

Last edited by Gee : November 30th, 2002 at 09:08 PM.

Reply With Quote
  #2  
Old November 29th, 2002, 02:01 PM
Kanu Kanu is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 91 Kanu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Most filetypes these days are designed to do that, eg, open in the helper application. It may not be a problem with your scripts at all.

Reply With Quote
  #3  
Old November 30th, 2002, 06:40 PM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
It is definately a problem in my script cause when I test it on a client instead of //localhost it just will not download the file - here is the script anyways - please if anyone can help me on this one #I would be very grateful been trying for ages with no avail - somebody must know !

PHP Code:
<?

//DB connection variables
$db mysql_connect("localhost""gee""ftm");

if (!
$db)
    {
    echo 
"Error: could not connect to database - Please try again later";
    exit;
    }

    
mysql_select_db("projectg");
    
$query "SELECT modCode, modTitle, lecturer, week, topics, filePath ";
    
$query .= "FROM lecfiles ";
    
$query .= "ORDER BY modCode, Week ASC";

    
$result mysql_query($query);

    if (!
$result) {
    echo 
"...............Couldn't get file list";
                    }

    
?>

    <!-- html table -->

    <img border=0 src="mdxlogo.gif"></a>

    <table border="1" cellpadding="0" cellspacing="0" bordercolor="#111111" width="100%">

      <tr>

        <td width="15%" bgcolor="#FF9900" height="21">
        <p style="margin-left: 10"><b><font size="2" face="Verdana" color="#FFFFFF">
        Module Code</font></b></td>

        <td width="15%" bgcolor="#FF9900" height="21">
        <p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">
        Mudule Title</font></b></td>

        <td width="15%" bgcolor="#FF9900" height="21">
        <p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">
        Lecturer</font></b></td>

        <td width="15%" bgcolor="#FF9900" height="21">
        <p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">
        Week</font></b></td>

        <td width="15%" bgcolor="#FF9900" height="21">
        <p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">
        Topics</font></b></td>

        <td width="15%" bgcolor="#FF9900" height="21">
        <p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">
        filePath</font></b></td>

      </tr>

    <?

    
while($row mysql_fetch_array($result))
    {

      
?>

      <tr>
      <td width="15%" bgcolor="#FFDCA8" height="21">
        <p style="margin-left: 10; margin-right: 10">
        <font face="Verdana" size="1">
            <?php echo "{$row['modCode']}"?>
        </font>
      </td>

      <td width="15%" bgcolor="#FFDCA8" height="21">
              <p style="margin-left: 10">
              <font face="Verdana" size="1">
                  <?php echo "{$row['modTitle']}"?>
              </font>
      </td>

      <td width="15%" bgcolor="#FFDCA8" height="21">
              <p style="margin-left: 10">
              <font face="Verdana" size="1">
                  <?php echo "{$row['lecturer']}"?>
              </font>
      </td>

      <td width="15%" bgcolor="#FFDCA8" height="21">
              <p style="margin-left: 10">
              <font face="Verdana" size="1">
                  <?php echo "{$row['week']}"?>
              </font>
      </td>

      <td width="15%" bgcolor="#FFDCA8" height="21">
              <p style="margin-left: 10">
              <font face="Verdana" size="1">
                  <?php echo "{$row['topics']}"?>
              </font>
      </td>

      <td width="15%" bgcolor="#FFDCA8" height="21">
              <p style="margin-left: 10">
              <font face="Verdana" size="1">
                  <!--got to investigate this -->
                  <a href="<?php echo "{$row['filePath']}"?>">Download now </a> <!-- DOES NOT WORK? -->
              </font>
      </td>


<?
    
}

     echo 
"</table>";

?>

Reply With Quote
  #4  
Old December 1st, 2002, 09:14 AM
Kanu Kanu is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 91 Kanu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
PHP Code:
<td width="15%" bgcolor="#FFDCA8" height="21">
              <
p style="margin-left: 10">
              <
font face="Verdana" size="1">
                  <!--
got to investigate this -->
                  <
a href="<?php echo "{$row['filePath']}"; ?>">Download now </a> <!-- DOES NOT WORK? -->
              </
font>
      </
td


What are those curled braces , eg "{" doing there? I wouldn't have put them in, but am I missing something?

Reply With Quote
  #5  
Old December 1st, 2002, 10:59 AM
Lindset Lindset is offline
weirdomoderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Alta, Norway
Posts: 370 Lindset User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via ICQ to Lindset Send a message via AIM to Lindset
Quote:
Originally posted by Kanu
What are those curled braces , eg "{" doing there? I wouldn't have put them in, but am I missing something?


It's used so the array will work.. When using arrays in the middle of strings, all of the following are correct:

echo "Here's the value: {$array['name']}"
echo "Here's the value: $array[name]";
echo "Here's the value: " . $array['name'];

the curly braces inside of string allows you to use arrays, access objects, etc like this:

echo "Here's the value: {$obj->getName()}";

Here's the manual entry for it. Scroll down until you hit Complex (curly) syntax: http://www.php.net/manual/en/language.types.string.php
__________________
Best Regards,
Håvard Lindset

Reply With Quote
  #6  
Old December 1st, 2002, 11:31 AM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
I still cannot get the damn files to download - changed allsorts - spent many hours reading and debugging but no result.

I recon its something very simple cause the thing works on \\localhost but not on clients.

Somebody, anybody.

What about those that downloaded my scripts - did you have a look at them, did you spot anything?

What do you think, any input at all to this problem is helpful.

As you can probably tell - I am now desperate!

Reply With Quote
  #7  
Old December 1st, 2002, 11:34 AM
Kanu Kanu is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 91 Kanu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
I just downloaded them now and will have a look. Oh, and side note to the mods/admin, can you install the quick reply hack to the board, it would make things so much easier...

Reply With Quote
  #8  
Old December 1st, 2002, 11:41 AM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
ThnX kanu,

I look forward to your input!

Reply With Quote
  #9  
Old December 1st, 2002, 11:44 AM
Kanu Kanu is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 91 Kanu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Right, running into the problems you describe... Hmm, can I ask a question? Why not use the database to store the file too? I mean, is there a particular reason for using disk storage? The BLOB Tutorial that we spoke about in the other thread could be very easily altered to do what you wish that way... I'm just not familiar with uploading to a file on a server as opposed to the BLOB method.

Reply With Quote
  #10  
Old December 1st, 2002, 11:52 AM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Well kanu, I had intended to use blobs to store the files at first, but then after reading up on the subject I found that this can severely overload mysql and slow things down immensly when large files are stored as blobs. For this reason I decided to store files in a directory.

Its typical, I get everthing running perfectly - file uploads, database storage for the data, but when I get to the very last part - everything goes pear shaped!

I couldnt get that blob tutorial to work anyway ( )

Reply With Quote
  #11  
Old December 1st, 2002, 12:05 PM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
One thing I have noticed is that when I change the following...
PHP Code:
 $filePath "C:\\FoxServ\\www\\lectures\\".$_FILES['yourFile']['name']; 

To for instance...
PHP Code:
 $filePath "169.254.215.214\\C:\\FoxServ\\www\\lectures\\".$_FILES['yourFile']['name']; 

And you click on the link to download the file in the browser - it includes the ipaddress followed by localhost followed by the filepath as the url -
PHP Code:
 http://169.254.215.214/localhost/C:/FoxServ/www/lectures/funny.doc 


very strange - I dont know why it is including both ipaddress and localhost - very strange?.

Reply With Quote
  #12  
Old December 1st, 2002, 12:28 PM
Kanu Kanu is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 91 Kanu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Quote:
Originally posted by Gee
Well kanu, I had intended to use blobs to store the files at first, but then after reading up on the subject I found that this can severely overload mysql and slow things down immensly when large files are stored as blobs. For this reason I decided to store files in a directory.

Its typical, I get everthing running perfectly - file uploads, database storage for the data, but when I get to the very last part - everything goes pear shaped!

I couldnt get that blob tutorial to work anyway ( )
I have a fine working version of the BLOB tutorial with additional fields in the database (keeps track of how often each blob has been downloaded etc...) that I'd happy give you. I'm sure the performance won't be hit at all as long as you organise the database properly. Make the table with a unique indexed primary key. Look at vBulletin for example, that's how it does attachments, as BLOBs, and it's as fast as fast can be

EDIT: Though it would be advantageous to have the actual BLOBs themselves in a seperate table if possible.

Last edited by Kanu : December 1st, 2002 at 12:30 PM.

Reply With Quote
  #13  
Old December 1st, 2002, 03:53 PM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
the thing is - i was wanting to get this working properly, you know when you sart something you wanna succeed.

I think I might as well just give up on a bad job!

So close yet so far

Reply With Quote
  #14  
Old December 1st, 2002, 04:15 PM
infamous-online infamous-online is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 403 infamous-online User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 27 m 25 sec
Reputation Power: 17
Quote:
Originally posted by Kanu
Right, running into the problems you describe... Hmm, can I ask a question? Why not use the database to store the file too? I mean, is there a particular reason for using disk storage? The BLOB Tutorial that we spoke about in the other thread could be very easily altered to do what you wish that way... I'm just not familiar with uploading to a file on a server as opposed to the BLOB method.


so how do you do that, i've been having major issues with it
__________________
Apache Expert

Reply With Quote
  #15  
Old December 1st, 2002, 04:26 PM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
asp_man,

did you download my scripts they are at the top of the thread, similar to BLOB except the files are stored in a directory.
works great apart from the file download part which only works on a \\localhost.

Reply With Quote
  #16  
Old December 1st, 2002, 06:58 PM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
here is the address for my scripts - anyone can view them, but they will be up for tonight only!

http://172.186.41.179/getdetails.php

or

http://172.186.41.179/showdetails.php

Reply With Quote
  #17  
Old December 1st, 2002, 09:06 PM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Ok,

I got it now so my links point to exactly the correct place on the server.

When I click to download though it says...
Forbidden
You don't have permission to access /C:/Foxserv/www/lectures/mpg1video.mpg on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

?any takers as to Y this is? Something to do with apache?

Reply With Quote
  #18  
Old December 1st, 2002, 09:29 PM
Attila Attila is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 67 Attila User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
I know I am not the best at this but you might want to look at my website.

I run a Squad based website for a game. I set up my rouster page to were my members update their own information and can upload a picture. The picture is automatically displayed. I just uploaded a .ext file for my picture and added a linking code and it worked no problem for me. My coding ability is very rough compared to everyone else but if you want to see my code I can drop it in here for you.

Too see the site it is this link.

Roster Link

I hope this can help.
__________________
Thanks,
Attila
http://www.glorynaspiration.com
http://www.abitofthings.com

Reply With Quote
  #19  
Old December 1st, 2002, 10:47 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 16
I was looking at your pages,....one of your problems is your links are absolute to the server, not for clients,...in that I mean,..your clients cannot access http://172.186.41.179/C:/Foxserv/www/lectures/

but they can access http://172.186.41.179/lectures/

does this make sense?

Hope it helps...
__________________
-- Jason

Reply With Quote
  #20  
Old December 1st, 2002, 11:42 PM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
That makes perfect sense,

And after changing the link - clients can now download the files no problem by right-clicking save as.

When they do a normal click however, the file just plays automatically - is there a way to force the download to use the save as / open / cancel menu box though?

Thank you VERY MUCH however! It is fantastic

PS. I have taken the pages down temp - I will put them back up later today though!

Reply With Quote
  #21  
Old December 2nd, 2002, 05:51 AM
Kanu Kanu is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 91 Kanu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Uploading to a file like that would be quite interesting to do. Do you have the "fixed" code that you can share? Oh, and if you do, a .sql file for the database would be nice.

Reply With Quote
  #22  
Old December 2nd, 2002, 06:25 AM
infamous-online infamous-online is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 403 infamous-online User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 27 m 25 sec
Reputation Power: 17
Quote:
Originally posted by Kanu
Uploading to a file like that would be quite interesting to do. Do you have the "fixed" code that you can share? Oh, and if you do, a .sql file for the database would be nice.


thats what i'm saying this would be very useful for me

Reply With Quote
  #23  
Old December 2nd, 2002, 08:58 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 16
Gee,....there is no way that I know of to do this,....unless,....when you upload the files,..you run them through gzip or something similer to zip them up,....that way they will always "Save Target As" instead of just opening in the default program

Reply With Quote
  #24  
Old December 2nd, 2002, 11:58 AM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Taelo.... I have heard of this problem as well and after reading up a bit on it it seems as though the following is a solution but not perfect by a long shot!


If extension is .txt, .doc, .xls and so on, send a ".zip header" to the browser, that MIGHT fool the browser that it's recieving something that it can't open, that way it will display the open?/save? box.
That is however depending on what the user has answered earlier in that box, you know, the little checkbox "always do like this when you get this type of file"... That part you have absolutley no control over.

Unfortunatley this solution isn't as reliable as it should be.
Usually a browser sends a request for a file, get's the file header, decides what to do and then displays it accordingly to the program/user settings.

IE however is a bit different since it's so tightly integrated with the OS. What IE does is actually two calls for each request. Like this, request file, examine header AND the actual file to determine if they match, if they don't, the examination of the actual file wins, in effect negates the sent headers. Then another call is made and the file is displayed accordingly to the result of the examination.

As you see, it's not that easy to decide for the browser what to do with what formats.

So, I think I will just put some text in the page to say "right click - 'save as' to save the file to your computer". Not perfect but that will have to do I think for the time being.

However, if anyone else has a solution, I'm also very interested in an example.

Reply With Quote
  #25  
Old December 2nd, 2002, 12:08 PM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Ok Guys...

I have no prbs sharing my "fixed" scripts - Let me clean the code up a little first and add some comments then I will post them for you to download.... it will probably be tomorrow.

You can let me know what you think

Gee

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > The Big one!


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap