APD1993 Posted February 2, 2012 Share Posted February 2, 2012 ...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! Quote Link to comment https://forums.phpfreaks.com/topic/256276-am-trying-to-get-a-program-working-where-the-user-can-upload-a-file/ Share on other sites More sharing options...
kicken Posted February 2, 2012 Share Posted February 2, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/256276-am-trying-to-get-a-program-working-where-the-user-can-upload-a-file/#findComment-1313779 Share on other sites More sharing options...
APD1993 Posted February 2, 2012 Author Share Posted February 2, 2012 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 :/ Quote Link to comment https://forums.phpfreaks.com/topic/256276-am-trying-to-get-a-program-working-where-the-user-can-upload-a-file/#findComment-1313780 Share on other sites More sharing options...
kicken Posted February 2, 2012 Share Posted February 2, 2012 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')); ? Quote Link to comment https://forums.phpfreaks.com/topic/256276-am-trying-to-get-a-program-working-where-the-user-can-upload-a-file/#findComment-1313781 Share on other sites More sharing options...
APD1993 Posted February 2, 2012 Author Share Posted February 2, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/256276-am-trying-to-get-a-program-working-where-the-user-can-upload-a-file/#findComment-1313786 Share on other sites More sharing options...
kicken Posted February 2, 2012 Share Posted February 2, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/256276-am-trying-to-get-a-program-working-where-the-user-can-upload-a-file/#findComment-1313790 Share on other sites More sharing options...
APD1993 Posted February 2, 2012 Author Share Posted February 2, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/256276-am-trying-to-get-a-program-working-where-the-user-can-upload-a-file/#findComment-1313791 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.