Reputation: 203
I'm trying to run a simple image upload script in php but when I open the browser and try to upload the image nothing happens. The browser spins and spins and eventually times out. I'm confused why this happens. Is there a setting that needs to be changed?
My Form
<html>
<body>
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
Choose a file to upload: <input name="uploaded_file" type="file" />
<input type="submit" value="Upload" name="upload" />
</form>
</body>
</html>
My php script
<?php
if(isset($_POST['upload'])){
echo $image_name = $_FILES['image']['name'];
echo $image_type = $_FILES['image']['type'];
echo $image_size = $_FILES['image']['size'];
echo $image_tmp_name = $_FILES['image']['tmp_name'];
}
?>
Upvotes: 1
Views: 31
Reputation: 11
Check the size of the file... it shouldn't be more than PHP.INI upload_max_filesize
(probably 2M on default). Your test file definitely should be smaller than that.
Also the form input is "uploaded_file" so the array with data should be: $_FILES['uploaded_file']
(try echo "test"; before or after everything next time!)
Also see php manual that haves a nice example: http://php.net/manual/en/features.file-upload.post-method.php
Upvotes: 1