Gossamer Forum
Home : General : Perl Programming :

PHP Upload...

Quote Reply
PHP Upload...
Hey. I've been playing with file uploads, but have been having a few problems with it. I am running it locally on my work computer, but for some reason the uplooaded file comes up as 'none', the path comes up ok, the size always comes out at zero and the type comes out ok. Here is an examples of what I see;

Code:
The name and path of file is none
The name and path of file is atpbase.sys
The size of file is 0
The size of file is application/octet-stream


The code I am using is;

Code:
<?php


if (!$uploadfile) { show_html(); } else { sendmain($uploadfile, $HTTP_POST_FILES['uploadfile']['name'], $HTTP_POST_FILES['uploadfile']['size'], $HTTP_POST_FILES['uploadfile']['type']); }

function show_html() {

?>

<form enctype="multipart/form-data" action="attach.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000">
Send this file: <input name="uploadfile" type="file">
<input type="submit" value="Send File">
</form>



<?

} // end the show html part


function sendmain($uploadfile_1, $uploadfile_2, $uploadfile_3, $uploadfile_4) {



echo "The name and path of file is $uploadfile_1<BR>";
echo "The name and path of file is $uploadfile_2 <BR>";
echo "The size of file is $uploadfile_3 <BR>";
echo "The size of file is $uploadfile_4 <BR>";

copy($uploadfile_1, "c:\\test\\test.txt");


}


function error($error) {
echo $error;
exit;
} // end the error sub



?>

and then URL i am referencing this from is the PHP.net site (http://www.php.net/...ures.file-upload.php).

Anyone ever played with file uploads and can give me a hand? I'm running PHP 4.0.6, which I think is the latest release.

Thanks

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] PHP Upload... In reply to
Hi Andy,

Please remove the line below or increase its value

<input type="hidden" name="MAX_FILE_SIZE" value="1000">

Cheers,



Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] PHP Upload... In reply to
Frown Still wont work. I had a thought that it may not be the script doing it. I downloaded another script which is;

Code:
<?

if ($superdat_name != "") {
copy("$superdat", "c:\\temp\\$superdat_name") or
die("Couldn't copy file.");

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

<html>
<head>
<title>phpUpLoad V 1.0</title>
<body bgcolor=white text=black link=blue>

<!--Header/Logo-->
<p align=center><img SRC="images/phpupload.gif" ALT="phpupload.gif"></p>

<p align=center>You sent: <? echo "$superdat_name"; ?>, a <? echo "$superdat_size"; ?>
byte file with a mime type of <? echo "$superdat_type"; ?>.</p>

<font size="2">
<p align=center><i>Comments or Questions? E-mail</i>
<a href="mailto:"john@experthost.com">Web-connected.com</a>&#169 2001
</font></p></center>
</body>
</html>

This seems to upload the file, but does not coppy it to the right directory. Is there something I have to define in php.ini or something before it will work?

Thanks

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] PHP Upload... In reply to
You should be using a single forward slash for paths on Windows. Only some irritating servers like IIS need double backslashes.
Quote Reply
Re: [RedRum] PHP Upload... In reply to
Oh...lol....I worked out my mistake Blush I was pointing it to c:\temp\, and uploading the file to it. However, I was getting confused as it was saying that the file was uploaded. What I forgot to mention was that I am calling the computer over a network. That meant that the file was being copied to a server that was over my network (which i am using as a web server for PHP test purposes). This has had me stumped for ages...and I really didnt want to admit to my mistake (which i just worked out Frown).....

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!