Solved

PHP upload

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Split wordpress loop 35 56
MVC - procedural PHP 10 34
mysql query for sum() 3 28
Wordpress Security 29 47
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

809 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