Link to home
Start Free TrialLog in
Avatar of mgtm3
mgtm3Flag for Israel

asked on

how do i give a dirictory in windows vista to write and read?

how do i give a dirictory in windows vista to write and read?

so i can upload files to it?
Avatar of purplepomegranite
purplepomegranite
Flag of United Kingdom of Great Britain and Northern Ireland image

Are you using IIS or Apache?

If IIS, you need to grant write permissions to the IUSR account (as that is the account which IIS will use to access the folder).
Avatar of mgtm3

ASKER

i dont know
i am using wamp

mysql
php

how do i know?
Avatar of mgtm3

ASKER

i am using Apache,
SOLUTION
Avatar of brad2575
brad2575
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In Apache on Windows, so long as the folder is within your web root folder, the default is that it is writable by PHP.
Avatar of mgtm3

ASKER

its not working i dont know why
i am tring to upoload i a file using php its not working
What is the error you are receiving?
Avatar of mgtm3

ASKER

no error its just nothing
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mgtm3

ASKER

i add it
i got no error
But you are just getting a blank page?  Should there be any output from your page (i.e. text)?  A blank page more often than not implies a syntax error in the code.  It may be worth posting the code here so that it can be double-checked.
Avatar of mgtm3

ASKER

this is the html code

<html>
<body>
  <form enctype="multipart/form-data" action="filephp.php" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="20000" />
    Choose a file to upload: <input name="ufile" type="file" />
    <input type="submit" value="Upload" />
  </form>
</body>
</html>


and this is the php code that when i click sumbet it goes to here
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
?>



<?php





$ufile=$_FILES['ufile'];
$name=$ufile['name'];
$type = strrchr("$name",".");
$type = substr($type, 1);


$tmplocation=$ufile['tmp_name'];
$size=$ufile['size']/1000;
$error=$ufile['error'];

if ($name=="")
echo "You need to choose a photo to upload";
else
{
echo $type;
if(($type!="jpg") && ($type!="jpeg") && ($type!="gif")&&($type!="bmp")&&($type!="png"))
{
echo "You can only upload a photo";
}
else
{
if($size>3)
echo 'the max size of the file is 3mb';
else
{

$newname = 'upload/'.$name;

   move_uploaded_file($_FILES['ufile']['tmp_name'], $newname);
   





}}}
The PHP had lots of errors in it.  Also, it helps to read it if you indent structures (such as if structures).

Attached is the code without syntax errors.  See if you get better results with it.
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$ufile=$_FILES['ufile'];
$name=$ufile['name'];
$type = substr(strrchr($name,"."), 1);
 
$tmplocation=$ufile['tmp_name'];
$size=$ufile['size']/1024;
$error=$ufile['error'];
 
if ($name=="") {
	echo "You need to choose a photo to upload"; }
else {
	echo $type;
	if(($type!="jpg") && ($type!="jpeg") && ($type!="gif")&&($type!="bmp")&&($type!="png")) {
		echo "You can only upload a photo";}
	else {
		if($size>3) {
			echo 'the max size of the file is 3mb'; }
		else {
			$newname = 'upload/'.$name;
			move_uploaded_file($_FILES['ufile']['tmp_name'], $newname);
		}
	}
}
 

Open in new window

Oh, apart from the fact I missed out the closing ?>.  Added in this code.
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$ufile=$_FILES['ufile'];
$name=$ufile['name'];
$type = substr(strrchr($name,"."), 1);
 
$tmplocation=$ufile['tmp_name'];
$size=$ufile['size']/1024;
$error=$ufile['error'];
 
if ($name=="") {
	echo "You need to choose a photo to upload"; }
else {
	echo $type;
	if(($type!="jpg") && ($type!="jpeg") && ($type!="gif")&&($type!="bmp")&&($type!="png")) {
		echo "You can only upload a photo";}
	else {
		if($size>3) {
			echo 'the max size of the file is 3mb'; }
		else {
			$newname = 'upload/'.$name;
			move_uploaded_file($_FILES['ufile']['tmp_name'], $newname);
		}
	}
}
?>

Open in new window

Avatar of mgtm3

ASKER

it dose not work