mgtm3
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?
so i can upload files to it?
ASKER
i dont know
i am using wamp
mysql
php
how do i know?
i am using wamp
mysql
php
how do i know?
ASKER
i am using Apache,
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
In Apache on Windows, so long as the folder is within your web root folder, the default is that it is writable by PHP.
ASKER
its not working i dont know why
i am tring to upoload i a file using php its not working
i am tring to upoload i a file using php its not working
What is the error you are receiving?
ASKER
no error its just nothing
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
i add it
i got no error
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.
ASKER
this is the html code
<html>
<body>
<form enctype="multipart/form-da ta" 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_n ame'];
$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!="b mp")&&($ty pe!="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);
}}}
<html>
<body>
<form enctype="multipart/form-da
<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_n
$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!="b
{
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
}}}
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.
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);
}
}
}
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);
}
}
}
?>
ASKER
it dose not work
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).