RE: question about some php code

  • From: Alex Parks <mehgcap@xxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sun, 21 Oct 2007 13:10:03 -0400

Okay, I copied the ip address code into a regular html file but it still doesn't work. The php still will not work either, but at least I am getting a real error whereas before I was getting the code of the page. Now it gives me a parse error at line 2 in uploader.php. I copied exactly what you had in your email. I think I am cursed when it comes to my programs doing what I want them to do. :


Have a great day,
Alex

----- Original Message -----
From: Ilian Andreev <ilian_andreev@xxxxxx
To: programmingblind@xxxxxxxxxxxxx
Date sent: Sun, 21 Oct 2007 12:24:32 +0300 (EEST)
Subject: RE: question about some php code

Hello, the reason why your code doesn`t execute is because PHP is
server-side language, i.e. it is only processed on the server. Thus when your print PHP statements via "echo" through your Javascript, which in terms is a client-side language, i.e. processed on your machine, you actually print pure HTML and text, and nothing happens. Note that you can do the reverse sometimes, print javascript via PHP and it will get executed because you pass it to the client-side. Hope you understood me here. I couldn`t figure out why you choose to print via javascript when you could simply echo-ed it: <?php echo'$REMOTE_ADDR';?>.

Now to the second question.

In your solution, you don`t actually upload the file but just
read its name and tmp_name. Use bool move_uploaded_file ( string $filename, string $destination ) to upload the file like this:

<?php
$target_path = 'upload/';
$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 "Sorry, there was a problem uploading your file.";
}
?

P.S. I changed the current dir to "upload" dir relative to the
uploader.php file because it didn`t work on my home Windows server with the current directory.

-----------------------------------------------------------------
ÅËÀ è íàïðàâè ñâîé ñàéò, îòêðèé íîâè ïðèÿòåëè!
WWW.ZOOM.BG
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind



__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: