Jump to content

Recommended Posts

Posted

Greetings All!

 

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.

 

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....

 

$filename = basename($fileupload_name);

$archivedir = "/files";

copy($fileupload, "$archivedir/$filename");

 

SOOOooooOOooo, can anyone see what I've mucked up???

 

Thanks

Knight Life

Posted

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

 

$var = "test";

echo '$var'; // this will output $var

echo "$var"; // this will output test

 

Further info about the error(s) PHP returned would be useful.

In the meanwhile, try changing your copy() command into this:

 

copy($fileupload, $archivedir."/".$filename);

Posted

I tried changing the " to ' made no difference.

I also tried using $archivedir."/".$filename, also no difference.

 

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...

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD>

<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>

<BODY></BODY></HTML>

 

I don't know that that helps much. I there a way that I can force a more useful error???

 

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!!

 

Thanks Again

Knight Life

Posted (edited)

Check my post on this thread in order to change the way error messages are displayed.

 

As for the full path to where your files reside, it's something like /home/<yourusername>/

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:

 

><?php
echo $_SERVER['DOCUMENT_ROOT'];
?>

 

Hope this helps :o

Edited by borfast
Posted

HEY THANKS GUYS!!! :o

 

Rock Sign

 

Raul, your code gave me the root dir that I needed (I was close, just needed the /home in front).

 

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)

 

Thanks Again Guys!! Thumbs Up

 

Knight Life

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...