problems with simple script

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

nick_k
New php-forum User
New php-forum User
Posts: 34
Joined: Wed Dec 25, 2002 6:04 am
Location: The Netherlands
Contact:

problems with simple script

Postby nick_k » Tue Feb 25, 2003 2:25 am

hi, i have this script, its not finished yet, but even this small piece doesnt work:

Code: Select all

<?php
session_start();
?>
<html>
<head>
  <title>File upload</title>
</head>

<body>

<?php
 
  if($_SESSION['passwd'] != $_SESSION['r_pass']) {
   
  print("<b>Incorrect password</b>");
  } //end if
  else {
 
  $userfile = $_POST['file'];
  $dir1 = "C:\Program Files\Apache Group\Apache\htdocs\naquiken website"; //change $dir1 to the directory that this script is in
  $dir2 = $dir1 . $userfile;

 
  }

?>

</body>
</html>


if for example the file was "test.jpg" the output should have been "C:\Program Files\Apache Group\Apache\htdocs\naquiken website\test.jpg" right? but the output is allways "C:\Program Files\Apache Group\Apache\htdocs aquiken website" any ideas?

Romantik
New php-forum User
New php-forum User
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson
Contact:

Postby Romantik » Tue Feb 25, 2003 2:57 am

$userfile = $_FILES['file']['name'];

nick_k
New php-forum User
New php-forum User
Posts: 34
Joined: Wed Dec 25, 2002 6:04 am
Location: The Netherlands
Contact:

Postby nick_k » Tue Feb 25, 2003 3:21 am

hey, thanks for replying, but i dont really know what the ['name'] part is?

Romantik
New php-forum User
New php-forum User
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson
Contact:

Postby Romantik » Tue Feb 25, 2003 3:24 am


nick_k
New php-forum User
New php-forum User
Posts: 34
Joined: Wed Dec 25, 2002 6:04 am
Location: The Netherlands
Contact:

Postby nick_k » Tue Feb 25, 2003 3:58 am

uhmmm that doesnt really help me....

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: problems with simple script

Postby WiZARD » Tue Feb 25, 2003 4:13 am

Hi nick_k!
try do this:

Code: Select all

  $dir1 = "C:\Program Files\Apache Group\Apache\htdocs\naquiken website\";

You forgot what you using Windows not Unix, if you in a future will use Unix this variant not worked.....

nick_k
New php-forum User
New php-forum User
Posts: 34
Joined: Wed Dec 25, 2002 6:04 am
Location: The Netherlands
Contact:

Postby nick_k » Tue Feb 25, 2003 4:22 am

hmm if i do that i get this error:
"Parse error: parse error, unexpected $end in c:\program files\apache group\apache\htdocs\naquiken website\upload.php on line 29"

Romantik
New php-forum User
New php-forum User
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson
Contact:

Postby Romantik » Tue Feb 25, 2003 4:25 am

use in future
$_SERVER["DOCUMENT_ROOT"]

Romantik
New php-forum User
New php-forum User
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson
Contact:

Postby Romantik » Tue Feb 25, 2003 4:31 am

send to this forum your code upload.php file, please

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: problems with simple script

Postby WiZARD » Tue Feb 25, 2003 4:36 am

of your quotas set correctly that's all done

Code: Select all

$dir1 = "C:\Program Files\Apache Group\Apache\htdocs\naquiken website\";
$dir2 = $dir1 . $userfile;


or try change at

Code: Select all

$dir1 = "C:\\Program Files\\Apache Group\\Apache\\htdocs\\naquiken website\\";
$dir2 = $dir1 . $userfile;

nick_k
New php-forum User
New php-forum User
Posts: 34
Joined: Wed Dec 25, 2002 6:04 am
Location: The Netherlands
Contact:

Postby nick_k » Tue Feb 25, 2003 4:56 am

ok heres my whole code, its really starting to piss me off now

Code: Select all

<?php
session_start();
?>
<html>
<head>
  <title>File upload</title>
</head>

<body>

<?php
 
  if($_SESSION['passwd'] != $_SESSION['r_pass']) {
   
  print("<b>Incorrect password</b>");
  } //end if
  else {
 
  $userfile = $_POST['file'];
  $dir1 = "C:\\Program Files\\Apache Group\\Apache\\htdocs\\naquiken website\\"; //change $dir1 to the directory that this script is in
  $dir2 = $dir1 . $userfile;
  copy($userfile, $dir2);
  unlink($userfile);

  $fp = fopen("count.dat", "r+");
  $contents = fread($fp, filesize("count.dat"));
 
  $n_name = $countents . ".jpg";
 
  $dir3 = $dir1 . $n_name;
  rename($dir2, $dir3);
  print("file saved!");

?>

</body>
</html>


it doesnt work, plus the " if($_SESSION['passwd'] != $_SESSION['r_pass']) " doesnt work, the script will act as if the password is correct in all situations, maby all these problems are because on y server configuration (i re-installed it all not long ago)

Romantik
New php-forum User
New php-forum User
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson
Contact:

Postby Romantik » Tue Feb 25, 2003 5:06 am

php.ini

safe_mode= off

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Tue Feb 25, 2003 5:20 am

speciall for nick, romantick and Wizard

Ia prosto prus s treh ukraincev kotorie govoriat na angliskom =)))

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Postby WiZARD » Tue Feb 25, 2003 5:33 am

Verish ya toje prikololsya dumal chto Nik burjuy a on kak ti govorish nash!
Nik ICQ vkluchay pobazarim! :^)


Return to “PHP coding => General”

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest

cron