6 Replies - 642 Views - Last Post: 03 September 2015 - 11:34 AM

#1 Cemgates101   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 34
  • Joined: 01-February 10

Providing User w/ Uploading Capabilities

Posted 03 September 2015 - 07:58 AM

What's up everyone!

I'm going through a PHP tutorial about providing uploading capabilities on a website. I have everything setup just like in the tutorial, but when I try to upload an image to the folder that I created in my file manager of my web host I get an error. I click on the upload button and then I get directed to an error page from my web host and it says "Error 403". Anybody run into this or have any ideas? I'm not paying for the site right now, so I am thinking that I just don't have that feature with the free account.

This is the html page:
<!DOCTYPE html>
<html>
<body>

<form action="uploadImage1.php method="post" enctype="multipart/form-data">
     Select image to upload:
     <input type="file" name="fileToUpload" id="fileToUpload">
     <input type="submit" value="Upload Image" name="submit">
</fom>

</body>
</html>



This is the PHP page:
<?php
$target_dir = "/uploads";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
//Check if image file is a actual image or fake image
if(isset($_POST["submit"])){
     $check = getimagesize($_FILES["fileToUpload"]["tmp_name]);
     if($check !== false){
          echo "File is an image - " . $check["mime"] . ".";
          $uploadOk = 1;
     }else{
           echo "File is not an image.";
           $uploadOk = 0;
      }
}
?>



I understand that there might be better ways to create this type of process, but I am going through a certain group of tutorials and this is what they gave. Any help will be very appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Providing User w/ Uploading Capabilities

#2 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2666
  • View blog
  • Posts: 10,645
  • Joined: 03-December 12

Re: Providing User w/ Uploading Capabilities

Posted 03 September 2015 - 08:21 AM

You would need write permission to upload a file.free accounts block it, because you are not paying for the space.
Was This Post Helpful? 1
  • +
  • -

#3 Cemgates101   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 34
  • Joined: 01-February 10

Re: Providing User w/ Uploading Capabilities

Posted 03 September 2015 - 08:43 AM

Cool,

That's what I figured. You don't have to go into detail, but is it possible, for tutorial sake, to get this to work on my pc?

Thanks!
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2666
  • View blog
  • Posts: 10,645
  • Joined: 03-December 12

Re: Providing User w/ Uploading Capabilities

Posted 03 September 2015 - 08:47 AM

Have you tried? As long as the server has write permission you should be fine.
Was This Post Helpful? 0
  • +
  • -

#5 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2102
  • View blog
  • Posts: 6,429
  • Joined: 15-January 14

Re: Providing User w/ Uploading Capabilities

Posted 03 September 2015 - 09:38 AM

Your form tag is missing a quote in the attributes, that might be an issue.
Was This Post Helpful? 0
  • +
  • -

#6 Cemgates101   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 34
  • Joined: 01-February 10

Re: Providing User w/ Uploading Capabilities

Posted 03 September 2015 - 10:39 AM

Thanks for the catch Artificial Solder,

I fixed it. Outcome is still the same.

astonecipher,

I have tried it a couple times, but it directs me to a page that says "hmm, can't reach that page". I'm just going to move on to the next tutorial for now. I'm sure it will be a little while before I am creating a website that needs this functionality.

Thank you though!
Was This Post Helpful? 0
  • +
  • -

#7 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2102
  • View blog
  • Posts: 6,429
  • Joined: 15-January 14

Re: Providing User w/ Uploading Capabilities

Posted 03 September 2015 - 11:34 AM

A 403 error means forbidden, so your host might be detecting the upload and blocking it. It could even just be checking for post requests with multipart/form-data enctypes and sending those to the 403 page.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1