/    Sign up×
Community /Pin to ProfileBookmark

I’m working on creating an upload site, but I need an upload script that will upload any file and has a [B]progress bar[/B].

can anyone help???

thanks.

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@JayMFeb 27.2008 — You wouldn't be able to have a progress bar using php only. You would also have to use perl to get information on how much of the file has been uploaded.

Try this:

http://tomas.epineer.se/archives/3
Copy linkTweet thisAlerts:
@steventowtauthorFeb 27.2008 — Well, I'm using this script here:

Is there anyway I can just add a progress bar or something, whether it being in php or not?

what's the simplest way?

<i>
</i>&lt;?
error_reporting(0);
$maxsize="3072";
$randomname="1";
$usetypes="1";
$types=array("jpg", "png", "bmp", "jpeg", "gif", "png", "zip", "rar");
$url="http://insanefiles.com/uploads/";
$folder="./uploads/";
$fullpath="";
$textcolor="#000000";
$textface="verdana";
$textsize="15px";
$pagebg="#CDCDCD";
$tablebg="#FFFFFF";
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;insanefiles.com&lt;/title&gt;
&lt;/head&gt;
&lt;style type="text/css"&gt;
a {color:blue;}
a {text-decoration:none; ;}
body{background-color:&lt;?Echo($pagebg);?&gt;;}
.text{font-face:&lt;?Echo($textface);?&gt;; font-size:&lt;?Echo($textsize);?&gt;; font-color:&lt;?Echo($textcolor);?&gt;;}
input{font-face:&lt;?Echo($textface);?&gt;; font-size:&lt;?Echo($textsize);?&gt;; font-color:&lt;?Echo($textcolor);?&gt;;}
&lt;/style&gt;
&lt;body&gt;
&lt;form action="&lt;?echo $_SERVER['PHP_SELF'];?&gt;" method="POST" enctype="multipart/form-data"&gt;
&lt;table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000" width="400" align="center" bgcolor="&lt;?Echo($tablebg);?&gt;" class="text"&gt;
&lt;tr&gt;
&lt;td colspan="2" align="center"&gt;&lt;b&gt;Allowed Types:&lt;/b&gt; &lt;?Echo(implode(", ",$types))?&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2" align="center"&gt;&lt;b&gt;Max File Size:&lt;/b&gt; &lt;?If(!$maxsize){Echo("No Limit");}Else{Echo($maxsize."kb");}?&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Select file to upload:&lt;/b&gt; &lt;/td&gt;
&lt;td&gt;&lt;input type="file" name="file"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;input type="hidden" name="doupload" value="True"&gt;
&lt;td colspan="2" align="center"&gt;&lt;input type="submit" name="doupload" value=" Upload File "&gt; &lt;input type="reset" name="reset" value=" Reset Form "&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;

&lt;?
If($fullpath){$folder=$fullpath;}
If(!$fullpath) {
$folder2=str_replace(".","",str_replace("/","",$folder));
If(!is_dir($folder2)) {
Echo("");
If(!@mkdir($folder2)) {
exit("");
} Else {
Echo("");

<i> </i> If(!@chmod($folder2,octdec("0777"))) {
<i> </i> exit("");
<i> </i> } Else {
<i> </i> Echo("");
<i> </i> }
<i> </i> }
<i> </i> }
}

If($_POST['doupload']) {
$file=$_FILES['file']['tmp_name'];
$size=$_FILES['file']['size'];
$type=$_FILES['file']['type'];
$name=strtolower($_FILES['file']['name']);
$ext=substr(strrchr($name, "."), 1);
$ext=str_replace("jpeg", "jpg", $ext);

<i> </i> If($randomname){
<i> </i> $rand=rand(0,100);
<i> </i> $name=$rand."_".time().".".$ext;
<i> </i> }

<i> </i> $error="";
<i> </i> If(!$file) {
<i> </i> $error="1";
<i> </i> $text .="&lt;b&gt;No file selected&lt;/b&gt;&lt;br /&gt;n";
<i> </i> }
<i> </i> If($file) {
<i> </i> If($maxsize) {
<i> </i> If($size &gt; ($maxsize*1024)) {
<i> </i> $error="1";
<i> </i> $text .="&lt;b&gt;Your file is to big&lt;/b&gt;&lt;br /&gt;n";
<i> </i> }
<i> </i> }
<i> </i> If($usetypes) {
<i> </i> If(!in_array($ext,$types)) {
<i> </i> $error="1";
<i> </i> $text .="&lt;b&gt;Invalid file type&lt;/b&gt;&lt;br /&gt;n";
<i> </i> }
<i> </i> }
<i> </i> If(file_exists($folder.$name)) {
<i> </i> $error="1";
<i> </i> $text .="&lt;b&gt;Please rename your file.&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;n";
<i> </i> }
<i> </i> }
<i> </i> If($error=="1") {
<i> </i> Echo("&lt;div align="center" class="text"&gt;$text&lt;/div&gt;n");
<i> </i> @unlink($file);
<i> </i> } Else {

<i> </i> @move_uploaded_file($file,$folder.$name) or die("Couldn't copy file to server, please make sure ".$folder." is chmod 777.");
<i> </i> exit("&lt;div align="center" class="text"&gt;&lt;b&gt;File uploaded! &lt;br /&gt;&lt;br /&gt;Your file: &lt;font color=blue&gt;&lt;a href=".$url.$name."&gt;".$url.$name."&lt;/a&gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;n");
<i> </i> }
}
?&gt;
Copy linkTweet thisAlerts:
@BrainDonorFeb 27.2008 — I just started looking at this. so far, it seems pretty cool.

http://www.element-it.com/multipowupload.aspx
Copy linkTweet thisAlerts:
@steventowtauthorFeb 28.2008 — okay, so I'm not worried about the progress bar right now.

but I have another question, using that same script as above, how can I make it where it can upload URLs too as well as local files???
Copy linkTweet thisAlerts:
@steventowtauthorFeb 29.2008 — another thing, the site is http://insanefiles.com, check it out, the problem I have is when I upload a .fla or .psd or .php and maybe a few others, they upload, but I can't view them nor can I download them as I normally would be able to, anyone know what's wrong with it???

http://insanefiles.com

thanks.
Copy linkTweet thisAlerts:
@MrCoderFeb 29.2008 — another thing, the site is http://insanefiles.com, check it out, the problem I have is when I upload a .fla or .psd or .php and maybe a few others, they upload, but I can't view them nor can I download them as I normally would be able to, anyone know what's wrong with it???

http://insanefiles.com

thanks.[/QUOTE]


File names, permissions or your code is at fault.

<i>
</i>$types=array("jpg", "png", "bmp", "jpeg", "gif", "png", "zip", "rar");


Add the types to the above array?
Copy linkTweet thisAlerts:
@steventowtauthorFeb 29.2008 — I did add those to it, that's not an updated code, they're added, and this is what happens when you view it after you upload it,

this is what I get for php:

http://insanefiles.com/uploads/61_1204317246.php

this is what I get for .psd and fla.

http://insanefiles.com/uploads/43_1204317714.fla

and I might get errors for other files.
Copy linkTweet thisAlerts:
@steventowtauthorMar 05.2008 — any help.
×

Success!

Help @steventowt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...