Uploading a file

M

Matt Fulford

Does anybody know any methods of allowing a user of your website to upload a
file they choose from their hard drive? For example, somebody looking at a
jobs website should have the option to press a button "Upload CV" and be
presented with a File Open dialog box in order to select the appropriate
file to upload.

Thanks
 
B

brucie

and you *know* he is using an IIS/ASP enabled server because?

its just a very bad guess. usage has been in decline for the last 3
years (just a little peak in sep 2001). only about 21% still use it.
 
T

Toby A Inkster

Leif said:
Anyone who would pay $150 for an upload script is either insane, rich,
or using their boss's money.

Very true. My PHP upload script on the intranet at work is 35 lines long
(and that does a decent amount of error checking). $150 for $35 lines of
code?

<?php
header("Content-Type: text/html");

function accept_upload ($d) {
$s = $_FILES['myfile']['tmp_name'];
move_uploaded_file($s,$d);
}

$dest = '/mnt/common' . $_POST['destination'];
if (is_dir($dest)) {
if (strlen($dest) < 14) {
$error = "Please put it in a folder -- not just in 'G:'";
} else {
if (strlen($_FILES['myfile']['name']) > 0) {
$dest .= $_FILES['myfile']['name'];
while (file_exists($dest)) {
$dest = "New upload of $dest";
}
accept_upload($dest);
} else {
$error = "It would help if you told me which file.";
}
}
} else {
$error = "Destination folder doesn't seem to exist!";
}

if ($error) {
?>
<title>Error</title>
<h1>Error</h1>
<p><?php echo $error; ?></p>
<?php
} else {
header('Location: /g/' . $_POST['destination']);
}
?>
 
W

Wipkip

While sitting in a puddle Toby A Inkster scribbled in the mud:
Leif said:
Anyone who would pay $150 for an upload script is either insane,
rich, or using their boss's money.

Very true. My PHP upload script on the intranet at work is 35 lines
long (and that does a decent amount of error checking). $150 for $35
lines of code?

<?php
header("Content-Type: text/html");

function accept_upload ($d) {
$s = $_FILES['myfile']['tmp_name'];
move_uploaded_file($s,$d);
}

$dest = '/mnt/common' . $_POST['destination'];
if (is_dir($dest)) {
if (strlen($dest) < 14) {
$error = "Please put it in a folder -- not
just in 'G:'";
} else {
if (strlen($_FILES['myfile']['name']) > 0) {
$dest .= $_FILES['myfile']['name'];
while (file_exists($dest)) {
$dest = "New upload of $dest";
}
accept_upload($dest);
} else {
$error = "It would help if you told me
which file.";
}
}
} else {
$error = "Destination folder doesn't seem to exist!";
}

if ($error) {
?>
<title>Error</title>
<h1>Error</h1>
<p><?php echo $error; ?></p>
<?php
} else {
header('Location: /g/' . $_POST['destination']);
}
?>

So is this script $150.00 or #35.00 a line. Kind of a big difference
there. ;)
 
W

William Tasso

Toby said:
Very true. My PHP upload script on the intranet at work is 35 lines
long (and that does a decent amount of error checking). $150 for $35
lines of code?

At 12 lines per day that works out at $50 per day. Good value I reckon ;o)
 
B

brucie

My PHP upload script on the intranet at work is 35 lines long
(and that does a decent amount of error checking). $150 for $35 lines of
code?

theres no limit on the size of the file you can upload.
 
R

Richard

Anyone who would pay $150 for an upload script is either insane, rich,
or using their boss's money.

Not to mention totally ignorant.

If they can develop the script, why can't you?
 
P

PW

William Tasso said:
At 12 lines per day that works out at $50 per day. Good value I reckon ;o)


That was my opinion too. Why write "yet another" upload program, when I
could just buy it for $150. I tried several others that were free prior to
purchasing, and had all sorts of problems. Plus I was under time pressure
from the client. So I bought a solution. Works really good too. :)
 
W

William Tasso

Richard said:
rich, > or using their boss's money.

Not to mention totally ignorant.
really?

If they can develop the script, why can't you?

The usual reasons that apply to any purchace vs build decision.

I have the skills necessary to build a house and a car. I have no intention
of building either, although I may turn my hand to a new garden shed now
that brucie appears to have taken residence in the existing one.

fyi: ASPupload is a server side component - not a script.
 
B

brucie

I have the skills necessary to build a house and a car. I have no intention
of building either, although I may turn my hand to a new garden shed now
that brucie appears to have taken residence in the existing one.

and i told you *last week* i wanted new carpet! where the hell is it?
 
M

Marc Nadeau

PW a écrit:
That was my opinion too. Why write "yet another" upload program, when I
could just buy it for $150. I tried several others that were free prior
to
purchasing, and had all sorts of problems. Plus I was under time pressure
from the client. So I bought a solution. Works really good too. :)


A $5 a line, i want to work for you sir. Choose your language.
 
T

Toby A Inkster

brucie said:
theres no limit on the size of the file you can upload.

Yes there is -- PHP enforces this limit itself. Search in "/etc/php.ini"
for "upload_max_filesize". Currently set to "2M" on my server and on the
intranet in question.
 
B

brucie

Yes there is -- PHP enforces this limit itself.

i knew that
Currently set to "2M" on my server and on the intranet in question.

wouldn't take much to shut down a 20Mb or even a 100Mb account. poor
little me did it on a 15mb account with just my crappy 14.4k connection
so i could prove a point to the "we don't need that" client. how about a
100k or 200k limit if you're uploading thingys like images with a max
limit of files.?
 
N

Nico Schuyt

brucie said:
theres no limit on the size of the file you can upload.

Some servers cut off when execution time exceeds a certain time (like mine:
max 300 seconds)
No matter if I use copy() or ftp_put()
Nico
 
H

Hywel Jenkins

Toby A Inkster said:
Leif said:
Anyone who would pay $150 for an upload script is either insane, rich,
or using their boss's money.

Very true. My PHP upload script on the intranet at work is 35 lines long
(and that does a decent amount of error checking). $150 for $35 lines of
code?

<?php
header("Content-Type: text/html");

function accept_upload ($d) {
$s = $_FILES['myfile']['tmp_name'];
move_uploaded_file($s,$d);

Might be worth checking that the file has been moved - just in case.

if (!move_uploaded_file($s,$d))
# Chuck an error
 
T

Toby A Inkster

brucie said:
wouldn't take much to shut down a 20Mb or even a 100Mb account.

But the target partition on the intranet has about 1.5GB free, and on my
own server I have about 15GB spare (really must tidy things up and get
myself some more room!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top