Jump to content

To get a file name, File Size, File Type...?


d22552000

Recommended Posts

Is there a way to get information about a file BEFORE it is submitted to the server?

 

I am trying to make a upload progress bar from scratch WITHOUT THE PRON.C PHP FIX!!!

 

I found the file being uploaded in my NET://WINN01910//TEMP folder and I can outputs its file size in a popup with a one second refrehs, but this makes it so the USER needs to know the full file size to know if its anywehre near done.  Is there a way to get the filesize from the clients side?  Possibly javascript that uses ajax to submit the values to the server before the file is sent but when it is selected??

 

Is there an easier way to do this and/or do you have any ajax example code of how it might work?

 

I also have another problem, Althoguh i can echo the filesize of what is recieved so far, I am just glob()ing the temp folder for: "php*.tmp" but is there a way to tell the tmp file so they don't see everyone's uploads?

Link to comment
Share on other sites

I am trying a few js based ones:

 

function imgLoad()
{
var strT = new String();
document.getElementById("ShowImg").innerHTML= "";
strT = document.ModReg.file1.value;
if(strT != "")
{
strT = "<img id='Sample' src='" + strT + "' width='100' height='100'></img>";
document.getElementById("ShowImg").innerHTML= strT;
if(!LimitedSize())
{
alert("File Size is more than 100 KB");
document.getElementById("ShowImg").innerHTML= "";
}
}
}

function LimitedSize()
{
var i;
var y = document.images;
for (i=0;i<y.length;i++)
{
if((y[i].id) == 'Sample')
{ 
if(y[i].fileSize > 102400)
return false;
}
}
return true;
}


//--------------HTML
<INPUT 
name=file1 type=file id="file1" onChange="imgLoad()" >

 

I am not sure about it though, it works, but VERY badly.  Please can anyone help?

Link to comment
Share on other sites

No need to fix/patch/whatever the php install. U can do it combining php with perl and megaupload script is an example. Ive seen u work on projects like 'a web server' so probably it would be nosense saying why are u creating this when it is there. Its always better to create your stuff, but in this case (and mostly in the 'web server' thing) it means reinventing the wheel :). Oh good luck by the way.

Link to comment
Share on other sites

hey, I HAVE made my own webserver and it works on windows, I am just trying to get chmodding to work under linux and then its perfect :D :D

 

I tried the mega upload php file upload, but it gives INTERNAL SERVER ERROR 500 on teh cgi script..

 

No info in the log file for cgi though... wtf/.

 

 

THE FUNNY Part is that their online demo returns 500, so this means their code sucks...

 

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, raditha@raditha.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


--------------------------------------------------------------------------------

Apache/2.0.52 (CentOS) Server at www.raditha.com Port 80

 

hahah idiots :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.