Solved

PHP upload

Posted on 2007-03-31
4
407 Views
Last Modified: 2008-03-06
Hi,

I am currently trying to upload a file using a webform and PHP. My code is below. I cannot understand what is wrong, when I hit to upload it just goes to the uploader.php file and never uploads. Doesn't display anything either.

I have created the folder in the /var/www/html/ called uploads

Its probably something easy, but I cannot work it out. I am not a programmer.

upload.htm

<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

uploader.php

$target_path = "uploads/";

$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 uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

Thanks
0
Comment
Question by:mark_06
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
mukhtar2t earned 125 total points
ID: 18831360
type
error_reporting(E_ALL);
at the top of your script and execute it again
0
 
LVL 2

Assisted Solution

by:wakemup
wakemup earned 125 total points
ID: 18831557
Make sure Apache has write access to the 'uploads/' directory.
0
 
LVL 6

Author Comment

by:mark_06
ID: 18831798
Thanks. It was the write access.
0
 
LVL 4

Expert Comment

by:mukhtar2t
ID: 18831802
You are welcome
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question