Solved

PHP upload

Posted on 2007-03-31
4
384 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
Comment Utility
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
Comment Utility
Make sure Apache has write access to the 'uploads/' directory.
0
 
LVL 6

Author Comment

by:mark_06
Comment Utility
Thanks. It was the write access.
0
 
LVL 4

Expert Comment

by:mukhtar2t
Comment Utility
You are welcome
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now