Jump to content

Archived

This topic is now archived and is closed to further replies.

predator12341

why wont this upload script work :(

Recommended Posts

Hi all the below code works fine in another project but not the one i am doing currently.

the folders have chmod of 777 so no write issues UPLOAD_PATH is set to the right upload path but i just cant think y it aint working everything looks fine.
please help
regards
Mark

sorry forgot to say it looks as if it is not getting the value inside the file input box i pass it yet it knows it is there as if i use the empty function it sees that there is something in there but when i need to use it in the below code it dont work :(

Code Below

$fileName = $_FILES['uploaded']['name'];
$target = UPLOAD_PATH;
$target = $target .'/'. $_FILES['uploaded']['name'];
echo $target;
$ok=1;

if ($fileName =="text/php")
{
echo "No PHP files<br>";
$ok="0";
}

if($ok == "0")
{
echo "Sorry, there was a problem uploading your file.";
}
else
{
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target);
}

Share this post


Link to post
Share on other sites
here :)
<form method="POST" action="pdfUploader.php">
*** code here that dont get transfered***

<input type="file" name="uploaded" />

*** code here that dont get transfered***

<input type="submit" name="upload" value="upload" />

*** code here that dont get transfered***

</form>

Share this post


Link to post
Share on other sites
$fileName = $_FILES['uploaded']['name'];

if ($fileName =="text/php")

aren't you setting the filename to be the actual name of the file? not the file type? not sure if that has anything to do with anything, but just an observation...

Share this post


Link to post
Share on other sites
that line checks to see it it is file type of .php that is not setting anything == means check not make

Share this post


Link to post
Share on other sites
You need to include [color=red]enctype="multipart/form-data"[/color] in your <form> tag.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.