Jump to content

Am trying to get a program working where the user can upload a file...


APD1993

Recommended Posts

...and the file is to be copied into a folder created by me. I was wondering what the file path would be for Windows, since it does not seem to recognise the file path that I have chosen:

 

Upload Form code:

<html>
<head><title>Car Accident Report Uploader</title></head>
<body>
<form action="fileuploadform.php" method="post" enctype="multipart/form-data">
<input type="file" size="45" name ="file"><br>
<input type="submit" value = "Upload Car Accident Report">
</form>
</body>
</html>

 

Copying Script Code:

<?php
if ($_FILES['file']['name'] !="") {
copy ($_FILES['file']['tmp_name'], 'C:\xampp\htdocs\rcm' . $_FILES['file']['name'])
	or die ("Could not copy Car Accident Report Form");
}
else {die ("No Car Accident Report Form has been chosen");}
?>
<html>
<head><title>Car Accident Report Form Upload Complete</title></head>
<body><h3>Car Accident Report Form has been uploaded</h3>

<ul>
<li>Sent: <?php echo $_FILES['file']['name']; ?>
<li>Size: <?php echo $_FILES['file']['size']; ?> bytes
<li>Type: <?php echo $_FILES['file']['type']; ?>

<a href = "<?php echo $_FILES['file']['name']; ?>">
Click here to view the Car Accident Report Form</a>
</body>
</html>

 

If anyone can help me find the relevant file path, it would be appreciated! :)

Link to comment
Share on other sites

So long as C:\xampp\htdocs\ exists and is writable by the server it should copy ok.  Do you get warnings or is the file just not showing up?  Does it upload successfully?

 

I don't believe that it does since

1) An error message appears

2)When I check the folder it should have been copied into, nothing is there :/

Link to comment
Share on other sites

I don't believe that it does since

1) An error message appears

Which is?

 

What does var_dump($_FILES); show?

 

What about var_dump(is_writable('C:\xampp\htdocs')); ?

 

The error message is:

 

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

 

If you think this is a server error, please contact the webmaster.

 

If I click on the referring page link, I get told:

 

Notice: Undefined index: file in C:\xampp\htdocs\fileuploadform.php on line 2

No Car Accident Report Form has been chosen

Link to comment
Share on other sites

The error message is:

 

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

That means your posting to the wrong URL.  You need to make sure your posting to your PHP file.

 

If I click on the referring page link, I get told:

 

Notice: Undefined index: file in C:\xampp\htdocs\fileuploadform.php on line 2

No Car Accident Report Form has been chosen

 

Your code that you posted is ment to be on the receiving end of your upload.  Your form should have it's action set to the url of that page.

 

 

Link to comment
Share on other sites

The error message is:

 

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

That means your posting to the wrong URL.  You need to make sure your posting to your PHP file.

 

If I click on the referring page link, I get told:

 

Notice: Undefined index: file in C:\xampp\htdocs\fileuploadform.php on line 2

No Car Accident Report Form has been chosen

 

Your code that you posted is ment to be on the receiving end of your upload.  Your form should have it's action set to the url of that page.

 

I believe that the form is linking to the .php file. How would I post to my .php file?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.