swamp Posted August 20, 2008 Share Posted August 20, 2008 Hi there - I have three php pages: add-author.php: <?php $file = "../../author/".$_POST['poster'].".txt"; $content = stripslashes($_POST['author-biog']); $fp = fopen($file,"w") or die ("Error opening file in write mode!"); fputs($fp,$content); fclose($fp) or die ("Error closing file!"); echo "<meta http-equiv=\"refresh\" content=\"0; url=../admin/index.php?action=newpost\" />\n"; ?> And imgupload.php: <? $target_path = "../../../images/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; echo "<meta http-equiv=\"refresh\" content=\"0; url=add-author.php\" />\n"; } ?> I also have a form to submit data from: <form action="add-author.php" method="post"> <input name="poster" id="poster" type="text" /> Author Name<br /> <textarea rows="2" cols="60" name="author-biog"></textarea> Author Biog<br /> <input name="uploadedfile" type="file" /> Author Image<br /> <input type="submit" value="Submit"> </form> At the moment its just doing the add-author.php functions, but I want it to also do the image upload from the "uploadfile" input box - I've tried combining the two scripts onto one page but it just echo's the error: There was an error uploading the file, please try again! from the imgupload.php page. Any advice on processing both the image upload and the add-author.php on submission of the form much appreciated! Thanks Link to comment https://forums.phpfreaks.com/topic/120523-combining-php-pages/ Share on other sites More sharing options...
r-it Posted August 20, 2008 Share Posted August 20, 2008 in your form tag, change it to this: <form action="add-author.php" method="post" enctype="multipart/form-data"> Link to comment https://forums.phpfreaks.com/topic/120523-combining-php-pages/#findComment-621075 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.