php - Image not moving to upload directory (tutorial) -


this seems pretty common issue, , i've been digging lot through questions specific situation...but can't find it.

i've been working dropzone.js tutorial found here: http://www.startutorial.com/articles/view/how-to-build-a-file-upload-form-using-dropzonejs-and-php

the ui showing fine , i'm noticing in tomcat log php file (see below) being called - but, image not being uploaded directory.

i'm running tomcat 7 on ubuntu 14.04. i've made sure directory has proper permissions (777). see code below:

index.html (only showing div form element- please assume dropzone.js file linked properly):

<h3>upload images</h3>         <form action="upload.php" class="dropzone" method="get" enctype="multipart/form-data">             <div class="fallback">             <input type="file" name="file" multiple/>             </div>         </form> 

upload.php:

<?php $ds = directory_separator; $storefolder = 'uploads';  if (!empty($_files)) {  $tempfile = $_files['file']['tmp_name']; $targetpath = dirname( __file__ ) . $ds. $storefolder . $ds; $targetfile =  $targetpath. $_files['file']['name']; move_uploaded_file($tempfile,$targetfile);  } ?> 

tomcat log:

[14/jun/2015:18:28:14 -0400] "get /imageuploader/ http/1.1" 200 2109 [14/jun/2015:18:28:14 -0400] "get /imageuploader/bootstrap/css/bootstrap.min.css http/1.1" 304 - [14/jun/2015:18:28:14 -0400] "get /imageuploader/css/main.css http/1.1" 304 - [14/jun/2015:18:28:14 -0400] "get /imageuploader/bootstrap/css/bootstrap-theme.min.css http/1.1" 304 - [14/jun/2015:18:28:14 -0400] "get /imageuploader/js/dropzone.js http/1.1" 304 - [14/jun/2015:18:28:14 -0400] "get /imageuploader/bootstrap/js/bootstrap.min.js http/1.1" 304 - [14/jun/2015:18:28:14 -0400] "get /imageuploader/css/dropzone.css http/1.1" 304 - [14/jun/2015:18:28:14 -0400] "get /imageuploader/bootstrap/fonts/glyphicons-halflings-regular.woff2 http/1.1" 304 - [14/jun/2015:18:28:19 -0400] "post /imageuploader/upload.php http/1.1" 200 317 

any thoughts on i'm missing file uploads directory?

the problem here you've specified method in form overriding method set inside js file related project files tutorial.

  • uploading files requires post method.

the code took page in regards form, following:

<form action="upload.php" class="dropzone"></form> 

and not imply method. use exact coded files tutorial , not modify them unless know you're doing.

so change form code to:

<form action="upload.php" class="dropzone" method="post" enctype="multipart/form-data"> 

the method set inside .js file found @ , related this, being https://raw.githubusercontent.com/enyo/dropzone/master/dist/dropzone.js

dropzone.prototype.defaultoptions = {       url: null,       method: "post", 

the enctype inside file:

 this.element.setattribute("enctype", "multipart/form-data"); 

so again, use codes , not yours.

then you've added <input type="file" name="file" multiple/>, isn't shown on page.

if gives trouble, try removing it.

visit official website drag , drop code:

and read entire documentation.

consult following on php.net:


add error reporting top of file(s) find errors.

<?php  error_reporting(e_all); ini_set('display_errors', 1);  // rest of code 

sidenote: error reporting should done in staging, , never production.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -