Php File Uploading Via Form

windows

Guest
Greetings All!<br /><br />As a ASP convert (yes I finally dumped the evil monopoly), I've been working in PHP for about 9 months and got most of it. <br /><br />That said I'm having a bunch of problems getting a form to upload files to my TCH website. I *think* I've got the actual code right (but I'm not holding my breath), what I think I have wrong is the path to copy the uploaded file to. Here is the core piece of code....<br /><br />$filename = basename($fileupload_name);<br />$archivedir = "/files";<br />copy($fileupload, "$archivedir/$filename");<br /><br />SOOOooooOOooo, can anyone see what I've mucked up???<br /><br />Thanks<br />Knight Life<!--content-->
Hi,<br /><br />Try changing the quotes to be '<br /><br />Also have you turned on debugging and if so, whats the error?<br /><br />Jim<!--content-->
Be carefull when changing the quotes from ' to " - a variable inside double quotes will be translated to it's value but a variable inside single quotes will not, thus if you have<br /><br />$var = "test";<br />echo '$var'; // this will output $var<br />echo "$var"; // this will output test<br /><br />Further info about the error(s) PHP returned would be useful.<br />In the meanwhile, try changing your copy() command into this:<br /><br />copy($fileupload, $archivedir."/".$filename);<!--content-->
I tried changing the " to ' made no difference.<br />I also tried using $archivedir."/".$filename, also no difference.<br /><br />You both asked for info on the errors, I'd love to help here but everything I have access to is about supressing errors. The copy statement was in a if statment to suppress its error. I removed it to a line of its own (and //'d the rest of the if) now when I run the upload I end up with a blank page which has the source code of...<br /><br /><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br /><HTML><HEAD><br /><META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD><br /><BODY></BODY></HTML><br /><br />I don't know that that helps much. I there a way that I can force a more useful error???<br /><br />Also I *think* my biggest question is, do I have the copy to path correct for my TCH website? IE on my old IIS box (ewe evil MS) the path would have been D:\InetPub\wwwroot\files, but I have no clue what the full path should be on the TCH server. I'd like the file to end up in the "files" directory in the root of my TCH space, but really anywhere I have access to would work!! <br /><br />Thanks Again<br />Knight Life<!--content-->
Hi,<br /><br />Turn on errors by looking at Ricks post here:<br /><br /><a href="http://www.totalchoicehosting.com/forums/index.php?showtopic=3296&hl=php%20upgrade&st=15" target="_blank">http://www.totalchoicehosting.com/forums/i...20upgrade&st=15</a><br /><br />And no, that not the path<br /><br />Jim<!--content-->
Check my post on <a href="http://www.totalchoicehosting.com/forums/index.php?showtopic=3367" target="_blank">this thread</a> in order to change the way error messages are displayed.<br /><br />As for the full path to where your files reside, it's something like /home/<yourusername>/<br />If you want to make sure (or if it's not the one I pointed and you want to find out what it is) make use of this PHP script:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />echo $_SERVER['DOCUMENT_ROOT'];<br />?><!--c2--></div><!--ec2--><br /><br />Hope this helps <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
HEY THANKS GUYS!!! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> <br /><br /> Rock Sign <br /><br />Raul, your code gave me the root dir that I needed (I was close, just needed the /home in front).<br /><br />Jim, your bit of code about turning Errors back on is god sent!! Why is that little secret not on the FAQs under something like "Why am I not getting errors?". I actually wrote in an error to try and get one and could not. The only suggestion I would have is instead of using error level 7, push it all the way to 2047 which reports ALL errors (I was surprised at the number of stupid little error I had, OOPS)<br /><br />Thanks Again Guys!! Thumbs Up <br /><br />Knight Life<!--content-->
 
Back
Top