Troubleshooting File Download Issues in PHP?

In summary: Can you please enlighten me on those functions?The undo and redo functions are just for reversing changes you've made to a document. To format a word, you would use the textarea's built-in formatting features, such as adding a border or changing the font. I can't think of a way to highlight the word without using an external plugin, sorry.As far as your disable resume download question, you might write out the file more slowly (flushing the contents to the client periodicaly) or delay the processing of the upload at the server.
  • #1
ngkamsengpeter
195
0
I want to place a video conferencing script on my webpage so that my member can use it but i don't know how to program it . Can anyone teach me ? Can i program it in php ?
 
Technology news on Phys.org
  • #2
Video conferencing? You'll definitely need either flash or java, and you'd need to program a server or use something like the Adobe Media Server.

You definitely can't do it with PHP alone and it's not something someone would be able to teach in a couple of posts. However, your best bet is to use Flash because it has a good Camera support. The flash plugin will acquire the video data and send it to a server of yours, which broadcasts that information to other users. The Adobe Media Server supports this.
 
Last edited:
  • #3
Do you know meebo,it can let the user chat with msn,yahoo or other IM in their webpage,how can it do that ?
 
  • #4
I am guessing that it logs into each respective messenger's network and combines them into one interface .. Then again I have no idea because I've never used or even heard of "meebo". Are you using some sort of php-powered CMS for this project?
 
Last edited:
  • #5
Do you mean something like MeeboMe http://www.meebome.com/ ?
These are third party plugins so you'd just drop them on your site following the manufacturer's directions.
 
  • #6
-Job- said:
Do you mean something like MeeboMe http://www.meebome.com/ ?
These are third party plugins so you'd just drop them on your site following the manufacturer's directions.
I just want to learn to create my one , anyone can help ?And do anybody now how to make a textarea become a editor instance just like tinymce . I want to make my own one , don't want to use tinymce, so any tutorial on it . Please help .
 
  • #7
I can't help you unless go do some research first and come back with some more specific questions. For Video Conferencing look into Flash. For doing something akin to TinyMCE Javascript is sufficient, but you need to have a fairly good understanding of it.
 
  • #8
-Job- said:
I can't help you unless go do some research first and come back with some more specific questions. For Video Conferencing look into Flash. For doing something akin to TinyMCE Javascript is sufficient, but you need to have a fairly good understanding of it.
I know a javascript and know how to do it for some of the function at the tinymce but just don't understand why a table or picture can be shown at the textarea ?How can it do that
 
  • #9
Another questions , how can i hide the exact link of a files from my members when they download files.
For example, the files is at www.something.com/something.zip[/url] , how can i hide it and show only something such as [PLAIN]www.something.com/download.php when my member download that files?
Is it possible to limit the download or upload speed of my member when they download files from my websites using php.
 
Last edited by a moderator:
  • #10
TinyMCE doesn't use a TextArea control. It probably uses a div which is manipulated to emulate a textarea, i.e. a div which captures keystrokes and updates its innerHTML attribute and uses an animation for the cursor.

As far as your download.php question you accomplish that by having the download.php script receive a variable, such as a file ID in the querystring, for instance: /download.php?fid=5.
The script then obtains the file (or file location) using the ID (i.e. by querying a database) and writes out the contents of the file setting the Content-Type header to the appropriate type and the Content-Disposition to "attachment; fileName=myFile.zip" for example.

For limiting download speed you may write out the file more slowly (flushing the contents to the client periodicaly). I can't think of a way to limit upload speed without using a Java applet. You might delay the processing of the upload at the server, but as far as controlling how fast the file is uploaded i can only think of a way to do it by using Java.
 
Last edited:
  • #11
what type of content-type header ? can you give me an example ?
 
  • #12
For example:
Code:
asf: ContentType = "video/x-ms-asf"
avi: ContentType = "video/avi"
doc: ContentType = "application/msword"
zip: ContentType = "application/zip"
xls: ContentType = "application/vnd.ms-excel"
gif: ContentType = "image/gif"
jpg: ContentType = "image/jpeg"
jpeg: ContentType = "image/jpeg"
wav: ContentType = "audio/wav"
mp3: ContentType = "audio/mpeg3"
mpg: ContentType = "video/mpeg"
mpeg: ContentType = "video/mpeg"
rtf: ContentType = "application/rtf"
htm: ContentType = "text/html"
html: ContentType = "text/html"
asp: ContentType = "text/asp"
 
Last edited:
  • #13
for the limit download speed, how to write out the file more slowly (flushing the contents to the client periodicaly),can you give a some of the sample code ?
 
  • #14
I know some download manager can let the user resume download .How can i disable this resume download for my sites.
And about the tinymce, a div ,ok now i understand most of it but i still don't understand some functions such as undo,redo and also how to highlight the word and format it.
 
  • #15
You can use the Javascript to get the highlighted text. Once you click the bold button for example it can replace the highlighted text in the div with <b>highlighted text here</b>, which makes the highlighted text bold. For undoing and redoing you can keep a list of changes that are made to the text.
 
  • #16
how about disabled the resume download function ?
 
  • #17
When you write a file to the client, if you include the header Accept-Ranges: bytes then resume download is supported.
If you don't want to support resuming you can set it to Accept-Ranges: none.
 
  • #18
Can you give me some code on how to write the file to client and limit the download speed, i don't very understand it .
I am facing another problem when using ajax , i use innerHTML=responseText to update the element html code when it receive responseText using ajax . The resposeText contain the html code and also the javascript tag but the javascrip tag doesn't work on this method. It seems like the javascript doesn't exist at all.How can i do to fix this problem ?
 
  • #19
You need to start using http://www.php.net" ):
PHP:
<?php
function readfile_chunked($filename,$retbytes=true) {
    $chunksize = 1*(1024*1024); // how many bytes per chunk
    $buffer = '';
    $cnt =0;
    // $handle = fopen($filename, 'rb');
    $handle = fopen($filename, 'rb');
    if ($handle === false) {
        return false;
    }
    while (!feof($handle)) {
        $buffer = fread($handle, $chunksize);
        echo $buffer;
        if ($retbytes) {
            $cnt += strlen($buffer);
        }
    }
        $status = fclose($handle);
    if ($retbytes && $status) {
        return $cnt; // return num. bytes delivered like readfile() does.
    } 
    return $status;

} 
?>

After writing a chunk you can have the code sleep for x seconds, see www.php.net[/url] about the sleep function [URL="http://http://us2.php.net/manual/en/function.sleep.php"]http://http://us2.php.net/manual/en/function.sleep.php[/URL].

Also, any <script> in the html you pass to an object's innerHTML property will be ignored. To overcome this limitation whenever needed i extract the javascript code in between the <script></script> tags and call eval(extractedScriptHere). The best/easiest way to extract the code is by using Regular Expressions [PLAIN]http://docs.sun.com/source/816-6408-10/regexp.htm"
 
Last edited by a moderator:
  • #20
This is my code but it don't work , it just run for once only doesn't loop.
for instance,i set the chunksize to 1 MB and the file i download is also 1 MB and then finish but the actual file size is 14 MB.This is the case when i use firefox.
When i use IE 6 , it doesn't download at all.
I see on the official php manual , it code also something like that but just use the default readfile functions .
So, What is the problem ? Is it my code wrong somewhere ?

<?php
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="downloaded.zip"');
readfile_chunked('test.zip');
function readfile_chunked($filename,$retbytes=true) {
$chunksize = 2*(100*100); // how many bytes per chunk
$buffer = '';
$cnt =0;
// $handle = fopen($filename, 'rb');
$handle = fopen($filename, 'rb');
if ($handle == false) {
return false;
}
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
echo $buffer;
if ($retbytes) {
$cnt += strlen($buffer);
}
}
$status = fclose($handle);
if ($retbytes && $status) {
return $cnt; // return num. bytes delivered like readfile() does.
}
return $status;

}

?>
 

1. What is a programming problem in website development?

A programming problem in website development refers to any issue or bug that arises during the process of creating or maintaining a website. It can involve coding errors, functionality issues, or design problems that prevent the website from functioning properly.

2. How can I identify a programming problem on my website?

The best way to identify a programming problem on your website is to regularly test and monitor its functionality. This can include checking for broken links, running regular updates and backups, and using web analytics tools to track user behavior and identify any issues that may arise.

3. What are some common causes of programming problems on websites?

Some common causes of programming problems on websites include coding errors, compatibility issues with different browsers and devices, outdated software or plugins, and security vulnerabilities.

4. How can I prevent programming problems on my website?

To prevent programming problems on your website, it is important to regularly update and maintain your website's software and plugins, use secure coding practices, and test your website on various browsers and devices. It is also helpful to have a backup plan in case any issues do arise.

5. What should I do if I encounter a programming problem on my website?

If you encounter a programming problem on your website, the first thing to do is to try and identify the cause of the issue. This can involve checking for any recent changes or updates, reviewing error logs, and seeking help from other developers or online resources. If the issue cannot be resolved, it may be necessary to hire a professional web developer to fix the problem.

Similar threads

  • Programming and Computer Science
Replies
9
Views
568
Replies
6
Views
620
  • Programming and Computer Science
Replies
9
Views
852
  • Programming and Computer Science
Replies
33
Views
2K
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
2
Replies
65
Views
2K
  • Programming and Computer Science
Replies
9
Views
2K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
21
Views
5K
Back
Top