Solved

PHP upload

Posted on 2007-03-31
4
413 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
emailing registered email addresses in phpmyadmin 5 69
Format Date 7 28
Change background images after 5 seconds. 12 47
Best hashing method? 1 21
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

739 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