RE: question about some php code

  • From: Ilian Andreev <ilian_andreev@xxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sun, 21 Oct 2007 12:24:32 +0300 (EEST)

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 

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:

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

ЕЛА и направи свой сайт, открий нови приятели!
View the list's information and change your settings at 

Other related posts: