| | |
Simple upload script not working
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 8
Reputation:
Solved Threads: 0
Hello, thanks so much for responding. The permissions are all OK.
Here is the hmtl form(slightly truncated - with the old data from the table called up with php echos):
<form action="news2.php" enctype="multipart/form-data" method="post">
<input type=hidden name="id" VALUE='<?php echo $row['id'] ?>'><input type="hidden" name="MAX_FILE_SIZE" value="350000"><tr>
<?php echo "<img src='files/news1.jpg'>"; ?><br /><input type="hidden" name="MAX_FILE_SIZE" value="10000" />Choose picture: <input name="news1" type="file" /><?php echo $row['section1'] ?></textarea></td>
</table><p><input name="upload" type="submit" value="Upload changes">
Which is passed on to a new page:
Here is the hmtl form(slightly truncated - with the old data from the table called up with php echos):
<form action="news2.php" enctype="multipart/form-data" method="post">
<input type=hidden name="id" VALUE='<?php echo $row['id'] ?>'><input type="hidden" name="MAX_FILE_SIZE" value="350000"><tr>
<?php echo "<img src='files/news1.jpg'>"; ?><br /><input type="hidden" name="MAX_FILE_SIZE" value="10000" />Choose picture: <input name="news1" type="file" /><?php echo $row['section1'] ?></textarea></td>
</table><p><input name="upload" type="submit" value="Upload changes">
Which is passed on to a new page:
php Syntax (Toggle Plain Text)
<?php $section1=$_POST['section1']; $section2=$_POST['section2']; $section3=$_POST['section3']; $section4=$_POST['section4']; $target_path = "files/"; $target_path = $target_path . basename( $_FILES['news1']['name']); move_uploaded_file($_FILES['news1']['tmp_name'], 'files/news1.jpg'); $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Can't connect: ' . mysql_error()); } mysql_select_db("database", $con); $query = "UPDATE news SET section1='$section1', section2='$section2', section3='$section3', section4='$section4' WHERE id='$id'"; $result = mysql_query($query); header ( 'Location: http://www.website.com/newsc.php' ); // close connection mysql_close(); ?>
Last edited by cscgal; Oct 13th, 2008 at 4:08 pm. Reason: Added code tags
•
•
Join Date: Jul 2004
Posts: 234
Reputation:
Solved Threads: 8
php Syntax (Toggle Plain Text)
move_uploaded_file($_FILES['news1']['tmp_name'], 'files/news1.jpg');
php Syntax (Toggle Plain Text)
move_uploaded_file($_FILES['news1']['tmp_name'], '/home/<your_username>/htdocs/files/news1.jpg');
![]() |
Similar Threads
- [For Hire] Freelance phpBB Installation Services (Post your Resume)
- updating text (PHP)
- Can't get exec() or system() to work. (PHP)
- problem in setting session (PHP)
- Internal Server Error (Perl)
Other Threads in the PHP Forum
- Previous Thread: PHP question about "while" loop
- Next Thread: Checkboxes
| Thread Tools | Search this Thread |
301 apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html httppost if...loop image include insert ip javascript joomla jquery key library limit link links login mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search searchbox server session sessions sms sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website youtube zend





