You are here: Javascript problem « PHP « IT news, forums, messages
Javascript problem

Posted by Gregg Healy on 01/17/05 18:48

I am trying to get the form below to make sure the file type for the upload
is a pdf file. The code below checks, but doesn¹t allow even a pdf file to
upload. Can anybody shed some light on this for me? Is there an easier way
to do this using JS?



<?php

echo '<html>
<head>
<title>test page</title>

<script type="text/JavaScript">
<!-- Begin
function TestFileType( fileName, fileTypes ) {
if (!fileName) return;

dots = fileName.split(".")
//get the part AFTER the LAST period.
fileType = "." + dots[dots.length-1];

return (fileTypes.join(".").indexOf(fileType) != -1) ?
alert(\'That file is OK!\') :
alert("Please only upload PDF format files with the correct .pdf extension.
Please select a new file and try again.");
}
// -->
</script>

</head>

<body>
<form method="post" action="upload.php" enctype="multipart/form-data">
<input type="hidden" name="filename" value="'.$name.'">
<input type="file" name="uploadfile">
<input type="button" name="Submit" value="Upload"
onclick="TestFileType(this.form.uploadfile.value, [\'pdf\'])"><br>
</body>
</html>
';

?>



--
Gregg Healy
Service Specials Direct
800 230-8268

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация