By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

Uploading Script!

P: n/a
i have a script that runs ok on the lycos webserver, but due to it
being unreliable, i've moved to another free server for testing. the
script is as follows:

PHP Code:
<?php

$store_dir = BASE_DIR."gallery/images/";

#check if the string of the file name given is more than one.
if( strlen($_POST['upfile']['name']) < 1 )
{
echo("Error! No files to upload... Exiting");
exit();
}
#check the directory exists
if( !is_dir($store_dir) )
{
echo("Specified directory is not valid... Exiting");
@unlink($_POST['upfile']['tmp_name']);
exit();
}
#copying the file
if( @copy($_POST['upfile']['tmp_name'] ,
$store_dir.$_POST['upfile']['name'] ) )
{
echo("Uploaded ".$_POST['upfile']['name']." successfully.");
}
else
{
echo("Upload of ".$_POST['upfile']['name']." to ".$store_dir."
failed!!!!<BR>");
}
@unlink($_POST['upfile']['tmp_name']);
echo BASE_DIR;
?>
and form:

PHP Code:
<head><body>
<form enctype="multipart/form-data" action="do_upload.php"
method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="8192">
<input name="upfile" type="file">
<input name="store_dir" type="hidden" value="/images/">
<input type="submit" value="Send File">
<input type="reset" value="reset">
</form>
</body></head>
but the problem is, the postdata is not being read by the script as it
exits at the first IF statement saying there is no file.

anyhelp?

thanks!

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.