View Full Version : Dynamic Uploads with PHP Question

11-05-2011, 06:29 PM
I've been working on this for several days now and decided it was time to ask for help.

I must have something in the wrong place in my code, text keeps appearing on my website that should not be there (a picture of it is attached). I thought all of that text was supposed to be "hidden text".

Next question will be; can I create a new folder, edit the path command and have all file upload there?

This is the page I'm having trouble with.

Thanks in advance.

11-05-2011, 09:29 PM
Your displayed text will be a simple html problem. If you have this page uploaded to a host somewhere, give us the link. If not, post the entire page code here & we'll be able to spot the problem.

Second question: I assume you are referring to your root directory in which case the answer is no. You need a database for that.

11-05-2011, 11:21 PM

Sorry about that, I knew better.


11-06-2011, 04:17 AM
OK, you've got a real mess going on here. Here is the bottom of your page:

<p> <label for="comment" class="fltlft">Comment:</label> <textarea name="comment" id="comment" cols="60" rows="10"></textarea> </p> <p>&nbsp;</p> <?php echo "<pre>";print_r($_FILES);echo "</pre>";$target_path = "C:/Documents and Settings/David/My Documents/Local Work/Remote/dwc/upload/".$_FILES['uploadedfile']['name'];move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><body><form enctype="multipart/form-data" action="uploader.php" method="POST"> <p> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /> <input type="submit" value="Upload File/SUBMIT" /> </p> <p>&nbsp;</p> <!-- end .content --> </p></form></body></html> </div> <div class="footer"> <p>SVHS WEBMASTER </p> <p>c/o David Crook 11908 Tanton Lane ▪ Charlotte, NC 28273 </p> <!-- end .footer --></div> <!-- end .container --></div></body></html>

Too many errors to even discuss, you've some reading to do.
But for now:
1) On your page and using the above as a reference, highlight everything starting with <?php and below it and delete it.
2) Replace with this:

<div class="footer">
<p>c/o David Crook
11908 Tanton Lane ▪ Charlotte, NC 28273 </p>
<!-- end .footer --></div>
<!-- end .container --></div>

3) The form action tag at the beginning is the place to specify your php script.
<form id="form1" name="form1" method="post" action="uploader.php">
I assume "uploader.php will reside in your root directory, if not, adjust the path.

Whatever host you are using will have php script instructions for uploading files. That script will belong in your uploader.php file. Again, you have some reading to do, but this will set you on the right path.

11-06-2011, 01:34 PM
Thanks John,

I thought I followed your tutorial to the "T", guess I was WRONG!

I'll try again later tonight and maybe I can follow it a little better.


11-06-2011, 04:17 PM
What tutorial? You mean something you found from the forum? Incidently, the first html box above straight-lined, so hard to read, but all it is is the bottom of your page.