Trying to copy this script

I like this file upload script

Uploaded to my server


am trying to duplicate the effect at
http://svr.teamluke.net/upload_images_test.php
I look at the console to see what the deal is

How do I change the MIME type of the 3 style sheets

got it, some of my links were off

ok, am trying to install this bad boy, and got a few problems…

I noticed the php file to handle the upload is located in the jQuery-File-Upload-9.18.0/server/php directory, I want to know if its possible change the location of that file to php (my folder) so I can simply add the file to my other php files and delete the jQuery-File-Upload-9.18.0 folder, I looked at the Uploadhandler.php file and saw this…

 'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/', 

and Im guessing I can change that code to allow uploads to a different directory, like

'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'../images/properties/'.$_POST['propertyID'],

ok?
I would think it would be as simple as changing the action of the form

<form id="fileupload" action="//jquery-file-upload.appspot.com/" method="POST" enctype="multipart/form-data" 
data-ng-app="demo" data-ng-controller="DemoFileUploadController" data-file-upload="options" 
data-ng-class="{'fileupload-processing': processing() || loadingFiles}">

no?

I thought the “…/” operator had to be at the start of a file path, not in the middle?

ok, I think this will be ok?

'upload_dir' => '../images/properties/'.$_POST['propertyID'],

Im trying to customize this plugin, I uploaded the DEMO to
http://svr.teamluke.net/jQuery-File-Upload-9.18.0/
which works great…
But im trying to get it working at
http://svr.teamluke.net/upload_images_test.php
and am having some problems,
I am trying to change the upload directory from the default (server/php/uploads) to another directory depending upon a hidden form variable (…/images/properties/{$_POST[‘propertyID’])
I am clueless on how to bring over the variable to the php page when the form is submitted

Surely it just arrives as a $_POST variable with whatever name you gave it in your <input type="hidden" code.?

sure, heres the forn

    <!-- The file upload form used as target for the file upload widget -->
    <form id="fileupload" action="//jquery-file-upload.appspot.com/" method="POST" enctype="multipart/form-data" data-ng-app="demo" data-ng-controller="DemoFileUploadController" data-file-upload="options" data-ng-class="{'fileupload-processing': processing() || loadingFiles}">
        <!-- Redirect browsers with JavaScript disabled to the origin page -->
        <noscript><input type="hidden" name="redirect" value="https://blueimp.github.io/jQuery-File-Upload/"></noscript>
        <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
        <div class="row fileupload-buttonbar">
            <div class="col-lg-7">
                <!-- The fileinput-button span is used to style the file input field as button -->
                <span class="btn btn-success fileinput-button" ng-class="{disabled: disabled}">
                    <i class="glyphicon glyphicon-plus"></i>
                    <span>Add files...</span>
                    <input type="file" name="files[]" multiple ng-disabled="disabled">
                </span>
                <!--<button type="button" class="btn btn-primary start" data-ng-click="submit()">
                    <i class="glyphicon glyphicon-upload"></i>
                    <span>Start upload</span>
                </button>
                <button type="button" class="btn btn-warning cancel" data-ng-click="cancel()">
                    <i class="glyphicon glyphicon-ban-circle"></i>
                    <span>Cancel upload</span>
                </button>-->
                <!-- The global file processing state -->
                <span class="fileupload-process"></span>
            </div>
            <!-- The global progress state -->
            <div class="col-lg-5 fade" data-ng-class="{in: active()}">
                <!-- The global progress bar -->
                <div class="progress progress-striped active" data-file-upload-progress="progress()"><div class="progress-bar progress-bar-success" data-ng-style="{width: num + '%'}"></div></div>
                <!-- The extended global progress state -->
                <div class="progress-extended">&nbsp;</div>
            </div>
        </div>
        <!-- The table listing the files available for upload/download -->
        <table class="table table-striped files ng-cloak">
            <tr data-ng-repeat="file in queue" data-ng-class="{'processing': file.$processing()}">
                <td data-ng-switch data-on="!!file.thumbnailUrl">
                    <div class="preview" data-ng-switch-when="true">
                        <a data-ng-href="{{file.url}}" title="{{file.name}}" download="{{file.name}}" data-gallery><img data-ng-src="{{file.thumbnailUrl}}" alt=""></a>
                    </div>
                    <div class="preview" data-ng-switch-default data-file-upload-preview="file"></div>
                </td>
                <td>
                    <p class="name" data-ng-switch data-on="!!file.url">
                        <span data-ng-switch-when="true" data-ng-switch data-on="!!file.thumbnailUrl">
                            <a data-ng-switch-when="true" data-ng-href="{{file.url}}" title="{{file.name}}" download="{{file.name}}" data-gallery>{{file.name}}</a>
                            <a data-ng-switch-default data-ng-href="{{file.url}}" title="{{file.name}}" download="{{file.name}}">{{file.name}}</a>
                        </span>
                        <span data-ng-switch-default>{{file.name}}</span>
                    </p>
                    <strong data-ng-show="file.error" class="error text-danger">{{file.error}}</strong>
                </td>
                <td>
                    <p class="size">{{file.size | formatFileSize}}</p>
                    <div class="progress progress-striped active fade" data-ng-class="{pending: 'in'}[file.$state()]" data-file-upload-progress="file.$progress()"><div class="progress-bar progress-bar-success" data-ng-style="{width: num + '%'}"></div></div>
                </td>
                <td>
                    <button type="button" class="btn btn-primary start" data-ng-click="file.$submit()" data-ng-hide="!file.$submit || options.autoUpload" data-ng-disabled="file.$state() == 'pending' || file.$state() == 'rejected'">
                        <i class="glyphicon glyphicon-upload"></i>
                        <span>Start</span>
                    </button>
                    <button type="button" class="btn btn-warning cancel" data-ng-click="file.$cancel()" data-ng-hide="!file.$cancel">
                        <i class="glyphicon glyphicon-ban-circle"></i>
                        <span>Cancel</span>
                    </button>
                    <button data-ng-controller="FileDestroyController" type="button" class="btn btn-danger destroy" data-ng-click="file.$destroy()" data-ng-hide="!file.$destroy">
                        <i class="glyphicon glyphicon-trash"></i>
                        <span>Delete</span>
                    </button>
                </td>
            </tr>
        </table>
<input type="hidden" name="propertyID' value='1'>
    </form>

do I simply change the php file from

'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/',
'upload_url' => $this->get_full_url().'/files/',

to

'upload_dir' => '../images/properties/'.$_POST['propertyID'].'/',
'upload_url' => $this->get_full_url().'../images/properties/'.$_POST['propertyID'].'/',

But since im changing the URL of the PHP file, how do I direct the form to be submitted to it then?

Something along those lines, as long as you fix the mismatched quotes on that line - you open the name with doubles and close it with singles, hence the syntax colouring is all wrong.

I still don’t think you can put “…/” inside a URL, though I’ve never tried it.

1 Like

ok, as of now, this is the result


(Which works and the uploaded content (images) are there.
I look at the source and notice the form tag

<form id="fileupload" action="//jquery-file-upload.appspot.com/" method="POST" enctype="multipart/form-data">

Thats a little confusing to me…
I simply put

print_r($_POST);

in the PHP page which handles the uploads and now the result is


(But the images are still there)

when I try and upload a picture I get

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.