Help uploading a file please

This is a discussion on Help uploading a file please within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hey guys, I am trying to get this script working to upload a file and it keeps saying there's ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-04-2003
Tom Lavier \(unmunge email before replying directly\)
 
Posts: n/a
Default Help uploading a file please

Hey guys, I am trying to get this script working to upload a file and it
keeps saying there's an error in copying the file. I've included as much as
I can to ask for help here. I've CHMODDED both the upload and files folders
to 777 as well.

Here's the culprits and a link to my phpinfo file.
http://www.romsbytom.com/upload1.html
http://www.romsbytom.com/upload2.html
http://www.romsbytom.com/php/phpinfo.php

Finally here is the contents of the upload1.php and upload2.php files:

upload1.php contents

<html>
<head>
<title>Upload File</title>
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
alink="#0000ff"
topmargin="0" marginheight="0">

<p>&nbsp;</p>
<div align=center width=98%><h3> Upload File</h2><FORM ACTION="upload2.php"
METHOD="POST" ENCTYPE="multipart/form-data">
<CENTER>
<TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0 id=news>
<tr><td><b> Name :</b> </td>
<td ><input type="text" name="name" size="40" maxlength="80" ></td></tr>
<tr >
<td width=113><b> email : </b> </td>
<td width=289><p><input type=text name="email" size=30>
</td>
</tr>

<tr >
<td width=113>
<p align=right><b>file to be sent: </b>
</td>
<td width=289>
<p><input type=file name="superdat" size=30></p>
</td>
</tr>
<tr>
<td colspan=2 align=center><b>Message:</b>
</td>
</tr>

<tr>
<td colspan=2 align=center>
<textarea name="message" rows="3" cols="40"></textarea> </td>
</tr>


</TABLE>
</CENTER>
<DIV ALIGN=CENTER>
<P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT NAME="submit"
VALUE="Upload File"></P>
</DIV>
</FORM>


</body>
</html>



upload2.php contents

<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>upload</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
alink="#0000ff"
topmargin="0" marginheight="0">

<?
$mailheaders = "File upload";

if ($email == "") {
} else {
die("No email address specified.");

}

if ($superdat_name == "") {
copy("$superdat", "/home/vidkid72/public_html/upload/files/$superdat_name")
or
die("Couldn't copy file.");

} else {
die("No input file specified.");
}

mail("tom@romsbytom.com","$mailheaders", "$email sent $superdat_name, a
$superdat_size byte file with a MIME type of $superdat_type \n nome :$name\n
message :$message");

?>

<html>
<head>

<body bgcolor=white text=black link=blue>

<!--Header/Logo-->
<p>&nbsp;</p>
<p>&nbsp;</p>

<p align=center><h3>Your upload has been successfully sent and I will be in
contact with you shortly!</h3></p>

<p align=center>You have uploaded: <? echo "$superdat_name"; ?>, a <? echo
"$superdat_size"; ?>
byte file with a mime type of <? echo "$superdat_type"; ?>.See your file <a
href="http://www.romsbytom.com\upload/files/<? echo "$superdat_name";
?>">here</a></p>
</body>
</html>


Thanks.

-Tom

--
http://www.romsbytom.com
EPROM Programming Service



Reply With Quote
  #2 (permalink)  
Old 12-04-2003
Tom Lavier \(unmunge email before replying directly\)
 
Posts: n/a
Default Re: Help uploading a file please

Oops, the correct links are:
http://www.romsbytom.com/upload1.php
http://www.romsbytom.com/upload2.php
http://www.romsbytom.com/php/phpinfo.php


"Tom Lavier (unmunge email before replying directly)"
<tlavierSTOP@SPAMsympatico.ca> wrote in message
news:gcKzb.12529$zf2.1440859@news20.bellglobal.com ...
> Hey guys, I am trying to get this script working to upload a file and it
> keeps saying there's an error in copying the file. I've included as much

as
> I can to ask for help here. I've CHMODDED both the upload and files

folders
> to 777 as well.
>
> Here's the culprits and a link to my phpinfo file.
> http://www.romsbytom.com/upload1.html
> http://www.romsbytom.com/upload2.html
> http://www.romsbytom.com/php/phpinfo.php
>
> Finally here is the contents of the upload1.php and upload2.php files:
>
> upload1.php contents
>
> <html>
> <head>
> <title>Upload File</title>
> </head>
>
> <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> alink="#0000ff"
> topmargin="0" marginheight="0">
>
> <p>&nbsp;</p>
> <div align=center width=98%><h3> Upload File</h2><FORM

ACTION="upload2.php"
> METHOD="POST" ENCTYPE="multipart/form-data">
> <CENTER>
> <TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0 id=news>
> <tr><td><b> Name :</b> </td>
> <td ><input type="text" name="name" size="40" maxlength="80" ></td></tr>
> <tr >
> <td width=113><b> email : </b> </td>
> <td width=289><p><input type=text name="email"

size=30>
> </td>
> </tr>
>
> <tr >
> <td width=113>
> <p align=right><b>file to be sent: </b>
> </td>
> <td width=289>
> <p><input type=file name="superdat" size=30></p>
> </td>
> </tr>
> <tr>
> <td colspan=2 align=center><b>Message:</b>
> </td>
> </tr>
>
> <tr>
> <td colspan=2 align=center>
> <textarea name="message" rows="3" cols="40"></textarea> </td>
> </tr>
>
>
> </TABLE>
> </CENTER>
> <DIV ALIGN=CENTER>
> <P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT NAME="submit"
> VALUE="Upload File"></P>
> </DIV>
> </FORM>
>
>
> </body>
> </html>
>
>
>
> upload2.php contents
>
> <!doctype html public "-//w3c//dtd html 3.2//en">
> <html>
> <head>
> <title>upload</title>
> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
> </head>
>
> <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> alink="#0000ff"
> topmargin="0" marginheight="0">
>
> <?
> $mailheaders = "File upload";
>
> if ($email == "") {
> } else {
> die("No email address specified.");
>
> }
>
> if ($superdat_name == "") {
> copy("$superdat",

"/home/vidkid72/public_html/upload/files/$superdat_name")
> or
> die("Couldn't copy file.");
>
> } else {
> die("No input file specified.");
> }
>
> mail("tom@romsbytom.com","$mailheaders", "$email sent $superdat_name, a
> $superdat_size byte file with a MIME type of $superdat_type \n nome

:$name\n
> message :$message");
>
> ?>
>
> <html>
> <head>
>
> <body bgcolor=white text=black link=blue>
>
> <!--Header/Logo-->
> <p>&nbsp;</p>
> <p>&nbsp;</p>
>
> <p align=center><h3>Your upload has been successfully sent and I will be

in
> contact with you shortly!</h3></p>
>
> <p align=center>You have uploaded: <? echo "$superdat_name"; ?>, a <? echo
> "$superdat_size"; ?>
> byte file with a mime type of <? echo "$superdat_type"; ?>.See your file

<a
> href="http://www.romsbytom.com\upload/files/<? echo "$superdat_name";
> ?>">here</a></p>
> </body>
> </html>
>
>
> Thanks.
>
> -Tom
>
> --
> http://www.romsbytom.com
> EPROM Programming Service
>
>
>



Reply With Quote
  #3 (permalink)  
Old 12-04-2003
 
Posts: n/a
Default Re: Help uploading a file please


"Tom Lavier (unmunge email before replying directly)"
<tlavierSTOP@SPAMsympatico.ca> wrote in message
news:42Ozb.12723$yd.1800584@news20.bellglobal.com. ..
> Oops, the correct links are:
> http://www.romsbytom.com/upload1.php
> http://www.romsbytom.com/upload2.php
> http://www.romsbytom.com/php/phpinfo.php
>
>
> "Tom Lavier (unmunge email before replying directly)"
> <tlavierSTOP@SPAMsympatico.ca> wrote in message
> news:gcKzb.12529$zf2.1440859@news20.bellglobal.com ...
> > Hey guys, I am trying to get this script working to upload a file and it
> > keeps saying there's an error in copying the file. I've included as

much
> as
> > I can to ask for help here. I've CHMODDED both the upload and files

> folders
> > to 777 as well.
> >
> > Here's the culprits and a link to my phpinfo file.
> > http://www.romsbytom.com/upload1.html
> > http://www.romsbytom.com/upload2.html
> > http://www.romsbytom.com/php/phpinfo.php
> >
> > Finally here is the contents of the upload1.php and upload2.php files:
> >
> > upload1.php contents
> >
> > <html>
> > <head>
> > <title>Upload File</title>
> > </head>
> >
> > <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> > alink="#0000ff"
> > topmargin="0" marginheight="0">
> >
> > <p>&nbsp;</p>
> > <div align=center width=98%><h3> Upload File</h2><FORM

> ACTION="upload2.php"
> > METHOD="POST" ENCTYPE="multipart/form-data">
> > <CENTER>
> > <TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0 id=news>
> > <tr><td><b> Name :</b> </td>
> > <td ><input type="text" name="name" size="40" maxlength="80"

></td></tr>
> > <tr >
> > <td width=113><b> email : </b> </td>
> > <td width=289><p><input type=text name="email"

> size=30>
> > </td>
> > </tr>
> >
> > <tr >
> > <td width=113>
> > <p align=right><b>file to be sent: </b>
> > </td>
> > <td width=289>
> > <p><input type=file name="superdat" size=30></p>
> > </td>
> > </tr>
> > <tr>
> > <td colspan=2 align=center><b>Message:</b>
> > </td>
> > </tr>
> >
> > <tr>
> > <td colspan=2 align=center>
> > <textarea name="message" rows="3" cols="40"></textarea> </td>
> > </tr>
> >
> >
> > </TABLE>
> > </CENTER>
> > <DIV ALIGN=CENTER>
> > <P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT NAME="submit"
> > VALUE="Upload File"></P>
> > </DIV>
> > </FORM>
> >
> >
> > </body>
> > </html>
> >
> >
> >
> > upload2.php contents
> >
> > <!doctype html public "-//w3c//dtd html 3.2//en">
> > <html>
> > <head>
> > <title>upload</title>
> > <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
> > </head>
> >
> > <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> > alink="#0000ff"
> > topmargin="0" marginheight="0">
> >
> > <?
> > $mailheaders = "File upload";
> >
> > if ($email == "") {
> > } else {
> > die("No email address specified.");
> >
> > }
> >
> > if ($superdat_name == "") {
> > copy("$superdat",

> "/home/vidkid72/public_html/upload/files/$superdat_name")
> > or
> > die("Couldn't copy file.");
> >
> > } else {
> > die("No input file specified.");
> > }
> >
> > mail("tom@romsbytom.com","$mailheaders", "$email sent $superdat_name, a
> > $superdat_size byte file with a MIME type of $superdat_type \n nome

> :$name\n
> > message :$message");
> >
> > ?>
> >
> > <html>
> > <head>
> >
> > <body bgcolor=white text=black link=blue>
> >
> > <!--Header/Logo-->
> > <p>&nbsp;</p>
> > <p>&nbsp;</p>
> >
> > <p align=center><h3>Your upload has been successfully sent and I will be

> in
> > contact with you shortly!</h3></p>
> >
> > <p align=center>You have uploaded: <? echo "$superdat_name"; ?>, a <?

echo
> > "$superdat_size"; ?>
> > byte file with a mime type of <? echo "$superdat_type"; ?>.See your file

> <a
> > href="http://www.romsbytom.com\upload/files/<? echo "$superdat_name";
> > ?>">here</a></p>
> > </body>
> > </html>
> >
> >
> > Thanks.
> >
> > -Tom
> >
> > --
> > http://www.romsbytom.com
> > EPROM Programming Service
> >
> >

I didnt try this code, but...

Your file actually gets uploaded to PHP's tmp directory.
It can be referenced by

$userfile = $HTTP_POST_FILES['superdat']['tmp_name'];

and then copied or moved

$newName = $HTTP_POST_FILES['superdat']['name'];

move_uploaded_file($userfile,
"/home/vidkid72/public_html/upload/files/$newName")








Reply With Quote
  #4 (permalink)  
Old 12-04-2003
 
Posts: n/a
Default Re: Help uploading a file please


"Tom Lavier (unmunge email before replying directly)"
<tlavierSTOP@SPAMsympatico.ca> wrote in message
news:42Ozb.12723$yd.1800584@news20.bellglobal.com. ..
> Oops, the correct links are:
> http://www.romsbytom.com/upload1.php
> http://www.romsbytom.com/upload2.php
> http://www.romsbytom.com/php/phpinfo.php
>
>
> "Tom Lavier (unmunge email before replying directly)"
> <tlavierSTOP@SPAMsympatico.ca> wrote in message
> news:gcKzb.12529$zf2.1440859@news20.bellglobal.com ...
> > Hey guys, I am trying to get this script working to upload a file and it
> > keeps saying there's an error in copying the file. I've included as

much
> as
> > I can to ask for help here. I've CHMODDED both the upload and files

> folders
> > to 777 as well.
> >
> > Here's the culprits and a link to my phpinfo file.
> > http://www.romsbytom.com/upload1.html
> > http://www.romsbytom.com/upload2.html
> > http://www.romsbytom.com/php/phpinfo.php
> >
> > Finally here is the contents of the upload1.php and upload2.php files:
> >
> > upload1.php contents
> >
> > <html>
> > <head>
> > <title>Upload File</title>
> > </head>
> >
> > <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> > alink="#0000ff"
> > topmargin="0" marginheight="0">
> >
> > <p>&nbsp;</p>
> > <div align=center width=98%><h3> Upload File</h2><FORM

> ACTION="upload2.php"
> > METHOD="POST" ENCTYPE="multipart/form-data">
> > <CENTER>
> > <TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0 id=news>
> > <tr><td><b> Name :</b> </td>
> > <td ><input type="text" name="name" size="40" maxlength="80"

></td></tr>
> > <tr >
> > <td width=113><b> email : </b> </td>
> > <td width=289><p><input type=text name="email"

> size=30>
> > </td>
> > </tr>
> >
> > <tr >
> > <td width=113>
> > <p align=right><b>file to be sent: </b>
> > </td>
> > <td width=289>
> > <p><input type=file name="superdat" size=30></p>
> > </td>
> > </tr>
> > <tr>
> > <td colspan=2 align=center><b>Message:</b>
> > </td>
> > </tr>
> >
> > <tr>
> > <td colspan=2 align=center>
> > <textarea name="message" rows="3" cols="40"></textarea> </td>
> > </tr>
> >
> >
> > </TABLE>
> > </CENTER>
> > <DIV ALIGN=CENTER>
> > <P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT NAME="submit"
> > VALUE="Upload File"></P>
> > </DIV>
> > </FORM>
> >
> >
> > </body>
> > </html>
> >
> >
> >
> > upload2.php contents
> >
> > <!doctype html public "-//w3c//dtd html 3.2//en">
> > <html>
> > <head>
> > <title>upload</title>
> > <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
> > </head>
> >
> > <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> > alink="#0000ff"
> > topmargin="0" marginheight="0">
> >
> > <?
> > $mailheaders = "File upload";
> >
> > if ($email == "") {
> > } else {
> > die("No email address specified.");
> >
> > }
> >
> > if ($superdat_name == "") {
> > copy("$superdat",

> "/home/vidkid72/public_html/upload/files/$superdat_name")
> > or
> > die("Couldn't copy file.");
> >
> > } else {
> > die("No input file specified.");
> > }
> >
> > mail("tom@romsbytom.com","$mailheaders", "$email sent $superdat_name, a
> > $superdat_size byte file with a MIME type of $superdat_type \n nome

> :$name\n
> > message :$message");
> >
> > ?>
> >
> > <html>
> > <head>
> >
> > <body bgcolor=white text=black link=blue>
> >
> > <!--Header/Logo-->
> > <p>&nbsp;</p>
> > <p>&nbsp;</p>
> >
> > <p align=center><h3>Your upload has been successfully sent and I will be

> in
> > contact with you shortly!</h3></p>
> >
> > <p align=center>You have uploaded: <? echo "$superdat_name"; ?>, a <?

echo
> > "$superdat_size"; ?>
> > byte file with a mime type of <? echo "$superdat_type"; ?>.See your file

> <a
> > href="http://www.romsbytom.com\upload/files/<? echo "$superdat_name";
> > ?>">here</a></p>
> > </body>
> > </html>
> >
> >
> > Thanks.
> >
> > -Tom
> >
> > --
> > http://www.romsbytom.com
> > EPROM Programming Service
> >
> >
> >

>
>


My last post wasnt complete.
You must move the file from the tmp location to your home directory


<?
$userfile = $HTTP_POST_FILES[superdat]['tmp_name'];
$userfile_name = $HTTP_POST_FILES[superdat]['name'];
$upfile = '/home/vidkid72/public_html/upload/files/ ' . $superdat_name;
move_uploaded_file($superdat, $upfile)
?>




Reply With Quote
  #5 (permalink)  
Old 12-05-2003
Tom Lavier \(unmunge email before replying directly\)
 
Posts: n/a
Default Re: Help uploading a file please

Thanks for the help but I'm not sure where to place that code.

<xyzzy> wrote in message news:6tadnRW5_ojTXlKiRVn-iw@comcast.com...
>
> "Tom Lavier (unmunge email before replying directly)"
> <tlavierSTOP@SPAMsympatico.ca> wrote in message
> news:42Ozb.12723$yd.1800584@news20.bellglobal.com. ..
> > Oops, the correct links are:
> > http://www.romsbytom.com/upload1.php
> > http://www.romsbytom.com/upload2.php
> > http://www.romsbytom.com/php/phpinfo.php
> >
> >
> > "Tom Lavier (unmunge email before replying directly)"
> > <tlavierSTOP@SPAMsympatico.ca> wrote in message
> > news:gcKzb.12529$zf2.1440859@news20.bellglobal.com ...
> > > Hey guys, I am trying to get this script working to upload a file and

it
> > > keeps saying there's an error in copying the file. I've included as

> much
> > as
> > > I can to ask for help here. I've CHMODDED both the upload and files

> > folders
> > > to 777 as well.
> > >
> > > Here's the culprits and a link to my phpinfo file.
> > > http://www.romsbytom.com/upload1.html
> > > http://www.romsbytom.com/upload2.html
> > > http://www.romsbytom.com/php/phpinfo.php
> > >
> > > Finally here is the contents of the upload1.php and upload2.php files:
> > >
> > > upload1.php contents
> > >
> > > <html>
> > > <head>
> > > <title>Upload File</title>
> > > </head>
> > >
> > > <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> > > alink="#0000ff"
> > > topmargin="0" marginheight="0">
> > >
> > > <p>&nbsp;</p>
> > > <div align=center width=98%><h3> Upload File</h2><FORM

> > ACTION="upload2.php"
> > > METHOD="POST" ENCTYPE="multipart/form-data">
> > > <CENTER>
> > > <TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0 id=news>
> > > <tr><td><b> Name :</b> </td>
> > > <td ><input type="text" name="name" size="40" maxlength="80"

> ></td></tr>
> > > <tr >
> > > <td width=113><b> email : </b> </td>
> > > <td width=289><p><input type=text name="email"

> > size=30>
> > > </td>
> > > </tr>
> > >
> > > <tr >
> > > <td width=113>
> > > <p align=right><b>file to be sent: </b>
> > > </td>
> > > <td width=289>
> > > <p><input type=file name="superdat"

size=30></p>
> > > </td>
> > > </tr>
> > > <tr>
> > > <td colspan=2 align=center><b>Message:</b>
> > > </td>
> > > </tr>
> > >
> > > <tr>
> > > <td colspan=2 align=center>
> > > <textarea name="message" rows="3" cols="40"></textarea> </td>
> > > </tr>
> > >
> > >
> > > </TABLE>
> > > </CENTER>
> > > <DIV ALIGN=CENTER>
> > > <P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT NAME="submit"
> > > VALUE="Upload File"></P>
> > > </DIV>
> > > </FORM>
> > >
> > >
> > > </body>
> > > </html>
> > >
> > >
> > >
> > > upload2.php contents
> > >
> > > <!doctype html public "-//w3c//dtd html 3.2//en">
> > > <html>
> > > <head>
> > > <title>upload</title>
> > > <meta http-equiv="content-type" content="text/html;

charset=iso-8859-1">
> > > </head>
> > >
> > > <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> > > alink="#0000ff"
> > > topmargin="0" marginheight="0">
> > >
> > > <?
> > > $mailheaders = "File upload";
> > >
> > > if ($email == "") {
> > > } else {
> > > die("No email address specified.");
> > >
> > > }
> > >
> > > if ($superdat_name == "") {
> > > copy("$superdat",

> > "/home/vidkid72/public_html/upload/files/$superdat_name")
> > > or
> > > die("Couldn't copy file.");
> > >
> > > } else {
> > > die("No input file specified.");
> > > }
> > >
> > > mail("tom@romsbytom.com","$mailheaders", "$email sent $superdat_name,

a
> > > $superdat_size byte file with a MIME type of $superdat_type \n nome

> > :$name\n
> > > message :$message");
> > >
> > > ?>
> > >
> > > <html>
> > > <head>
> > >
> > > <body bgcolor=white text=black link=blue>
> > >
> > > <!--Header/Logo-->
> > > <p>&nbsp;</p>
> > > <p>&nbsp;</p>
> > >
> > > <p align=center><h3>Your upload has been successfully sent and I will

be
> > in
> > > contact with you shortly!</h3></p>
> > >
> > > <p align=center>You have uploaded: <? echo "$superdat_name"; ?>, a <?

> echo
> > > "$superdat_size"; ?>
> > > byte file with a mime type of <? echo "$superdat_type"; ?>.See your

file
> > <a
> > > href="http://www.romsbytom.com\upload/files/<? echo "$superdat_name";
> > > ?>">here</a></p>
> > > </body>
> > > </html>
> > >
> > >
> > > Thanks.
> > >
> > > -Tom
> > >
> > > --
> > > http://www.romsbytom.com
> > > EPROM Programming Service
> > >
> > >
> > >

> >
> >

>
> My last post wasnt complete.
> You must move the file from the tmp location to your home directory
>
>
> <?
> $userfile = $HTTP_POST_FILES[superdat]['tmp_name'];
> $userfile_name = $HTTP_POST_FILES[superdat]['name'];
> $upfile = '/home/vidkid72/public_html/upload/files/ ' . $superdat_name;
> move_uploaded_file($superdat, $upfile)
> ?>
>
>
>
>



Reply With Quote
  #6 (permalink)  
Old 12-05-2003
 
Posts: n/a
Default Re: Help uploading a file please


"Tom Lavier (unmunge email before replying directly)"
<tlavierSTOP@SPAMsympatico.ca> wrote in message
news:4wUzb.13750$yd.1978168@news20.bellglobal.com. ..
> Thanks for the help but I'm not sure where to place that code.
>
> <xyzzy> wrote in message news:6tadnRW5_ojTXlKiRVn-iw@comcast.com...
> >
> > "Tom Lavier (unmunge email before replying directly)"
> > <tlavierSTOP@SPAMsympatico.ca> wrote in message
> > news:42Ozb.12723$yd.1800584@news20.bellglobal.com. ..
> > > Oops, the correct links are:
> > > http://www.romsbytom.com/upload1.php
> > > http://www.romsbytom.com/upload2.php
> > > http://www.romsbytom.com/php/phpinfo.php
> > >
> > >
> > > "Tom Lavier (unmunge email before replying directly)"
> > > <tlavierSTOP@SPAMsympatico.ca> wrote in message
> > > news:gcKzb.12529$zf2.1440859@news20.bellglobal.com ...
> > > > Hey guys, I am trying to get this script working to upload a file

and
> it
> > > > keeps saying there's an error in copying the file. I've included as

> > much
> > > as
> > > > I can to ask for help here. I've CHMODDED both the upload and files
> > > folders
> > > > to 777 as well.
> > > >
> > > > Here's the culprits and a link to my phpinfo file.
> > > > http://www.romsbytom.com/upload1.html
> > > > http://www.romsbytom.com/upload2.html
> > > > http://www.romsbytom.com/php/phpinfo.php
> > > >
> > > > Finally here is the contents of the upload1.php and upload2.php

files:
> > > >
> > > > upload1.php contents
> > > >
> > > > <html>
> > > > <head>
> > > > <title>Upload File</title>
> > > > </head>
> > > >
> > > > <body bgcolor="#ffffff" text="#000000" link="#0000ff"

vlink="#0000ff"
> > > > alink="#0000ff"
> > > > topmargin="0" marginheight="0">
> > > >
> > > > <p>&nbsp;</p>
> > > > <div align=center width=98%><h3> Upload File</h2><FORM
> > > ACTION="upload2.php"
> > > > METHOD="POST" ENCTYPE="multipart/form-data">
> > > > <CENTER>
> > > > <TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0

id=news>
> > > > <tr><td><b> Name :</b> </td>
> > > > <td ><input type="text" name="name" size="40" maxlength="80"
> > ></td></tr>
> > > > <tr >
> > > > <td width=113><b> email : </b> </td>
> > > > <td width=289><p><input type=text name="email"
> > > size=30>
> > > > </td>
> > > > </tr>
> > > >
> > > > <tr >
> > > > <td width=113>
> > > > <p align=right><b>file to be sent: </b>
> > > > </td>
> > > > <td width=289>
> > > > <p><input type=file name="superdat"

> size=30></p>
> > > > </td>
> > > > </tr>
> > > > <tr>
> > > > <td colspan=2 align=center><b>Message:</b>
> > > > </td>
> > > > </tr>
> > > >
> > > > <tr>
> > > > <td colspan=2 align=center>
> > > > <textarea name="message" rows="3" cols="40"></textarea> </td>
> > > > </tr>
> > > >
> > > >
> > > > </TABLE>
> > > > </CENTER>
> > > > <DIV ALIGN=CENTER>
> > > > <P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT

NAME="submit"
> > > > VALUE="Upload File"></P>
> > > > </DIV>
> > > > </FORM>
> > > >
> > > >
> > > > </body>
> > > > </html>
> > > >
> > > >
> > > >
> > > > upload2.php contents
> > > >
> > > > <!doctype html public "-//w3c//dtd html 3.2//en">
> > > > <html>
> > > > <head>
> > > > <title>upload</title>
> > > > <meta http-equiv="content-type" content="text/html;

> charset=iso-8859-1">
> > > > </head>
> > > >
> > > > <body bgcolor="#ffffff" text="#000000" link="#0000ff"

vlink="#0000ff"
> > > > alink="#0000ff"
> > > > topmargin="0" marginheight="0">
> > > >
> > > > <?
> > > > $mailheaders = "File upload";
> > > >
> > > > if ($email == "") {
> > > > } else {
> > > > die("No email address specified.");
> > > >
> > > > }
> > > >
> > > > if ($superdat_name == "") {
> > > > copy("$superdat",
> > > "/home/vidkid72/public_html/upload/files/$superdat_name")
> > > > or
> > > > die("Couldn't copy file.");
> > > >
> > > > } else {
> > > > die("No input file specified.");
> > > > }
> > > >
> > > > mail("tom@romsbytom.com","$mailheaders", "$email sent

$superdat_name,
> a
> > > > $superdat_size byte file with a MIME type of $superdat_type \n nome
> > > :$name\n
> > > > message :$message");
> > > >
> > > > ?>
> > > >
> > > > <html>
> > > > <head>
> > > >
> > > > <body bgcolor=white text=black link=blue>
> > > >
> > > > <!--Header/Logo-->
> > > > <p>&nbsp;</p>
> > > > <p>&nbsp;</p>
> > > >
> > > > <p align=center><h3>Your upload has been successfully sent and I

will
> be
> > > in
> > > > contact with you shortly!</h3></p>
> > > >
> > > > <p align=center>You have uploaded: <? echo "$superdat_name"; ?>, a

<?
> > echo
> > > > "$superdat_size"; ?>
> > > > byte file with a mime type of <? echo "$superdat_type"; ?>.See your

> file
> > > <a
> > > > href="http://www.romsbytom.com\upload/files/<? echo

"$superdat_name";
> > > > ?>">here</a></p>
> > > > </body>
> > > > </html>
> > > >
> > > >
> > > > Thanks.
> > > >
> > > > -Tom
> > > >
> > > > --
> > > > http://www.romsbytom.com
> > > > EPROM Programming Service
> > > >
> > > >
> > > >
> > >
> > >

> >
> > My last post wasnt complete.
> > You must move the file from the tmp location to your home directory
> >
> >
> > <?
> > $userfile = $HTTP_POST_FILES[superdat]['tmp_name'];
> > $userfile_name = $HTTP_POST_FILES[superdat]['name'];
> > $upfile = '/home/vidkid72/public_html/upload/files/ ' . $superdat_name;
> > move_uploaded_file($superdat, $upfile)
> > ?>
> >
> >
> >
> >

>


Sorry.
It processes the results of your form (file upload)
So, at the top of upload2.php


>



Reply With Quote
  #7 (permalink)  
Old 12-05-2003
Ian Pawson
 
Posts: n/a
Default Re: Help uploading a file please

My code for processing the upload form is:-
$uploaddir = $CFG->imagedir . "/";
$uploadfile = $uploaddir. $_FILES['userfile']['name'];

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "<p class=h2>File is valid, and was successfully uploaded.</p>";
print "<p class=h3>Here's some file info</p>";
print "<p class=h3>Type: ";
print $_FILES['userfile']['type'];
print "<p class=h3>Size: ";
print $_FILES['userfile']['size'];
print " bytes.";

// now make a thumbnail
Makethumb($_FILES['userfile']['name']);
} else {
print "<p class=h2>File upload error!!</p>";
print "<p class=h2>Here's some debugging info:</p>";
print "<p class=h3>Type: ";
print $_FILES['userfile']['type'];
print "<p class=h3>Size: ";
print $_FILES['userfile']['size'];
print " bytes.";
print "<p class=h3>Error code: ";
print $_FILES['userfile']['error'];
}



"Tom Lavier (unmunge email before replying directly)"
<tlavierSTOP@SPAMsympatico.ca> wrote in message
news:42Ozb.12723$yd.1800584@news20.bellglobal.com. ..
> Oops, the correct links are:
> http://www.romsbytom.com/upload1.php
> http://www.romsbytom.com/upload2.php
> http://www.romsbytom.com/php/phpinfo.php
>
>
> "Tom Lavier (unmunge email before replying directly)"
> <tlavierSTOP@SPAMsympatico.ca> wrote in message
> news:gcKzb.12529$zf2.1440859@news20.bellglobal.com ...
> > Hey guys, I am trying to get this script working to upload a file and it
> > keeps saying there's an error in copying the file. I've included as

much
> as
> > I can to ask for help here. I've CHMODDED both the upload and files

> folders
> > to 777 as well.
> >
> > Here's the culprits and a link to my phpinfo file.
> > http://www.romsbytom.com/upload1.html
> > http://www.romsbytom.com/upload2.html
> > http://www.romsbytom.com/php/phpinfo.php
> >
> > Finally here is the contents of the upload1.php and upload2.php files:
> >
> > upload1.php contents
> >
> > <html>
> > <head>
> > <title>Upload File</title>
> > </head>
> >
> > <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> > alink="#0000ff"
> > topmargin="0" marginheight="0">
> >
> > <p>&nbsp;</p>
> > <div align=center width=98%><h3> Upload File</h2><FORM

> ACTION="upload2.php"
> > METHOD="POST" ENCTYPE="multipart/form-data">
> > <CENTER>
> > <TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0 id=news>
> > <tr><td><b> Name :</b> </td>
> > <td ><input type="text" name="name" size="40" maxlength="80"

></td></tr>
> > <tr >
> > <td width=113><b> email : </b> </td>
> > <td width=289><p><input type=text name="email"

> size=30>
> > </td>
> > </tr>
> >
> > <tr >
> > <td width=113>
> > <p align=right><b>file to be sent: </b>
> > </td>
> > <td width=289>
> > <p><input type=file name="superdat" size=30></p>
> > </td>
> > </tr>
> > <tr>
> > <td colspan=2 align=center><b>Message:</b>
> > </td>
> > </tr>
> >
> > <tr>
> > <td colspan=2 align=center>
> > <textarea name="message" rows="3" cols="40"></textarea> </td>
> > </tr>
> >
> >
> > </TABLE>
> > </CENTER>
> > <DIV ALIGN=CENTER>
> > <P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT NAME="submit"
> > VALUE="Upload File"></P>
> > </DIV>
> > </FORM>
> >
> >
> > </body>
> > </html>
> >
> >
> >
> > upload2.php contents
> >
> > <!doctype html public "-//w3c//dtd html 3.2//en">
> > <html>
> > <head>
> > <title>upload</title>
> > <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
> > </head>
> >
> > <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> > alink="#0000ff"
> > topmargin="0" marginheight="0">
> >
> > <?
> > $mailheaders = "File upload";
> >
> > if ($email == "") {
> > } else {
> > die("No email address specified.");
> >
> > }
> >
> > if ($superdat_name == "") {
> > copy("$superdat",

> "/home/vidkid72/public_html/upload/files/$superdat_name")
> > or
> > die("Couldn't copy file.");
> >
> > } else {
> > die("No input file specified.");
> > }
> >
> > mail("tom@romsbytom.com","$mailheaders", "$email sent $superdat_name, a
> > $superdat_size byte file with a MIME type of $superdat_type \n nome

> :$name\n
> > message :$message");
> >
> > ?>
> >
> > <html>
> > <head>
> >
> > <body bgcolor=white text=black link=blue>
> >
> > <!--Header/Logo-->
> > <p>&nbsp;</p>
> > <p>&nbsp;</p>
> >
> > <p align=center><h3>Your upload has been successfully sent and I will be

> in
> > contact with you shortly!</h3></p>
> >
> > <p align=center>You have uploaded: <? echo "$superdat_name"; ?>, a <?

echo
> > "$superdat_size"; ?>
> > byte file with a mime type of <? echo "$superdat_type"; ?>.See your file

> <a
> > href="http://www.romsbytom.com\upload/files/<? echo "$superdat_name";
> > ?>">here</a></p>
> > </body>
> > </html>
> >
> >
> > Thanks.
> >
> > -Tom
> >
> > --
> > http://www.romsbytom.com
> > EPROM Programming Service
> >
> >
> >

>
>



Reply With Quote
  #8 (permalink)  
Old 12-05-2003
Ian Pawson
 
Posts: n/a
Default Re: Help uploading a file please

Sorry, did not mean to use the 'makethumbs' bit.

"Ian Pawson" <ian@ipawson.com> wrote in message
news:3fd0bb63$0$9388$cc9e4d1f@news-text.dial.pipex.com...
> My code for processing the upload form is:-
> $uploaddir = $CFG->imagedir . "/";
> $uploadfile = $uploaddir. $_FILES['userfile']['name'];
>
> if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
> print "<p class=h2>File is valid, and was successfully uploaded.</p>";
> print "<p class=h3>Here's some file info</p>";
> print "<p class=h3>Type: ";
> print $_FILES['userfile']['type'];
> print "<p class=h3>Size: ";
> print $_FILES['userfile']['size'];
> print " bytes.";
>
> // now make a thumbnail
> Makethumb($_FILES['userfile']['name']);
> } else {
> print "<p class=h2>File upload error!!</p>";
> print "<p class=h2>Here's some debugging info:</p>";
> print "<p class=h3>Type: ";
> print $_FILES['userfile']['type'];
> print "<p class=h3>Size: ";
> print $_FILES['userfile']['size'];
> print " bytes.";
> print "<p class=h3>Error code: ";
> print $_FILES['userfile']['error'];
> }
>
>
>
> "Tom Lavier (unmunge email before replying directly)"
> <tlavierSTOP@SPAMsympatico.ca> wrote in message
> news:42Ozb.12723$yd.1800584@news20.bellglobal.com. ..
> > Oops, the correct links are:
> > http://www.romsbytom.com/upload1.php
> > http://www.romsbytom.com/upload2.php
> > http://www.romsbytom.com/php/phpinfo.php
> >
> >
> > "Tom Lavier (unmunge email before replying directly)"
> > <tlavierSTOP@SPAMsympatico.ca> wrote in message
> > news:gcKzb.12529$zf2.1440859@news20.bellglobal.com ...
> > > Hey guys, I am trying to get this script working to upload a file and

it
> > > keeps saying there's an error in copying the file. I've included as

> much
> > as
> > > I can to ask for help here. I've CHMODDED both the upload and files

> > folders
> > > to 777 as well.
> > >
> > > Here's the culprits and a link to my phpinfo file.
> > > http://www.romsbytom.com/upload1.html
> > > http://www.romsbytom.com/upload2.html
> > > http://www.romsbytom.com/php/phpinfo.php
> > >
> > > Finally here is the contents of the upload1.php and upload2.php files:
> > >
> > > upload1.php contents
> > >
> > > <html>
> > > <head>
> > > <title>Upload File</title>
> > > </head>
> > >
> > > <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> > > alink="#0000ff"
> > > topmargin="0" marginheight="0">
> > >
> > > <p>&nbsp;</p>
> > > <div align=center width=98%><h3> Upload File</h2><FORM

> > ACTION="upload2.php"
> > > METHOD="POST" ENCTYPE="multipart/form-data">
> > > <CENTER>
> > > <TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0 id=news>
> > > <tr><td><b> Name :</b> </td>
> > > <td ><input type="text" name="name" size="40" maxlength="80"

> ></td></tr>
> > > <tr >
> > > <td width=113><b> email : </b> </td>
> > > <td width=289><p><input type=text name="email"

> > size=30>
> > > </td>
> > > </tr>
> > >
> > > <tr >
> > > <td width=113>
> > > <p align=right><b>file to be sent: </b>
> > > </td>
> > > <td width=289>
> > > <p><input type=file name="superdat"

size=30></p>
> > > </td>
> > > </tr>
> > > <tr>
> > > <td colspan=2 align=center><b>Message:</b>
> > > </td>
> > > </tr>
> > >
> > > <tr>
> > > <td colspan=2 align=center>
> > > <textarea name="message" rows="3" cols="40"></textarea> </td>
> > > </tr>
> > >
> > >
> > > </TABLE>
> > > </CENTER>
> > > <DIV ALIGN=CENTER>
> > > <P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT NAME="submit"
> > > VALUE="Upload File"></P>
> > > </DIV>
> > > </FORM>
> > >
> > >
> > > </body>
> > > </html>
> > >
> > >
> > >
> > > upload2.php contents
> > >
> > > <!doctype html public "-//w3c//dtd html 3.2//en">
> > > <html>
> > > <head>
> > > <title>upload</title>
> > > <meta http-equiv="content-type" content="text/html;

charset=iso-8859-1">
> > > </head>
> > >
> > > <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff"
> > > alink="#0000ff"
> > > topmargin="0" marginheight="0">
> > >
> > > <?
> > > $mailheaders = "File upload";
> > >
> > > if ($email == "") {
> > > } else {
> > > die("No email address specified.");
> > >
> > > }
> > >
> > > if ($superdat_name == "") {
> > > copy("$superdat",

> > "/home/vidkid72/public_html/upload/files/$superdat_name")
> > > or
> > > die("Couldn't copy file.");
> > >
> > > } else {
> > > die("No input file specified.");
> > > }
> > >
> > > mail("tom@romsbytom.com","$mailheaders", "$email sent $superdat_name,

a
> > > $superdat_size byte file with a MIME type of $superdat_type \n nome

> > :$name\n
> > > message :$message");
> > >
> > > ?>
> > >
> > > <html>
> > > <head>
> > >
> > > <body bgcolor=white text=black link=blue>
> > >
> > > <!--Header/Logo-->
> > > <p>&nbsp;</p>
> > > <p>&nbsp;</p>
> > >
> > > <p align=center><h3>Your upload has been successfully sent and I will

be
> > in
> > > contact with you shortly!</h3></p>
> > >
> > > <p align=center>You have uploaded: <? echo "$superdat_name"; ?>, a <?

> echo
> > > "$superdat_size"; ?>
> > > byte file with a mime type of <? echo "$superdat_type"; ?>.See your

file
> > <a
> > > href="http://www.romsbytom.com\upload/files/<? echo "$superdat_name";
> > > ?>">here</a></p>
> > > </body>
> > > </html>
> > >
> > >
> > > Thanks.
> > >
> > > -Tom
> > >
> > > --
> > > http://www.romsbytom.com
> > > EPROM Programming Service
> > >
> > >
> > >

> >
> >

>
>



Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:05 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0