Solved

PHP upload

Posted on 2007-03-31
4
424 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

615 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