|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
both files are in the same directory... for practical reasons..
a simple page.. <?php require_once('cc_upload.php'); $up = new cs_upload; if(isset($_POST['submit'])) { $up -> uploadDocument($this->$_FILES['ffilename']['name']); } ?> <table border="1"> <form action="home3.php" enctype="multipart/form-data" method="post"> <tr> <td width="101">Podcast MP3 </td> <td width="207"><input type="file" name="ffilename" width="200" id="ffilename"></td> </tr> <tr> <td colspan="2"><input name="submit" type="submit" id="submit" value="submit"></td> </tr> <tr> <td colspan="2"></td> </tr> </form> </table> this is my class: <?php class cs_upload { var $fname; // file name that is uploaded function cs_upload() { $this ->fname = ' '; function uploadDocument($fname=' ') { //Move the file over. $uploadDir = '../uploads/'; $uploadFile = $uploadDir . $_FILES['ffilename']['name']; $uploadName = $_FILES['ffilename']['name']; if (move_uploaded_file($_FILES['ffilename']['tmp_name'], $uploadFile)) { chmod($uploadFile, 0655); } } } } ?> but I keep receiving: Fatal error: Call to undefined function: uploaddocument() in /home/ blah/public_html/blah/home3.php on line 8 thanks, |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
vncntj wrote: > both files are in the same directory... for practical reasons.. > a simple page.. > > <?php > > require_once('cc_upload.php'); > $up = new cs_upload; > > if(isset($_POST['submit'])) > { > $up -> uploadDocument($this->$_FILES['ffilename']['name']); > } > > ?> > <table border="1"> > <form action="home3.php" enctype="multipart/form-data" > method="post"> > <tr> > <td width="101">Podcast MP3 </td> > <td width="207"><input type="file" name="ffilename" > width="200" id="ffilename"></td> > </tr> > <tr> > <td colspan="2"><input name="submit" type="submit" id="submit" > value="submit"></td> > </tr> > <tr> > <td colspan="2"></td> > </tr> > </form> > </table> > > this is my class: > > <?php > > class cs_upload > { > > var $fname; // file name that is uploaded > > function cs_upload() > { > $this ->fname = ' '; > > function uploadDocument($fname=' ') > { > //Move the file over. > > $uploadDir = '../uploads/'; > $uploadFile = $uploadDir . $_FILES['ffilename']['name']; > $uploadName = $_FILES['ffilename']['name']; > > if (move_uploaded_file($_FILES['ffilename']['tmp_name'], > $uploadFile)) > { > chmod($uploadFile, 0655); > } > } > } > } > ?> > > but I keep receiving: > > Fatal error: Call to undefined function: uploaddocument() in /home/ > blah/public_html/blah/home3.php on line 8 > > thanks, You've defined the uploaddocument() function inside cs_upload() function. As such uploaddocument() doesn't exist outside the constructor. This is what you currently have: function cs_upload() { //do constructor stuff here function uploaddocument() { //do upload stuff here } } When it should look like this: function cs_upload() { //do constructor stuff here } function uploaddocument() { //do upload stuff here } |
|
![]() |
| Outils de la discussion | |
|
|