masdaa
Forum Replies Created
-
Forum: Plugins
In reply to: [Wordpress File Upload] Run script on completed uploadYeah I played around with that a little, but can’t get it working. No matter what the file name does not change. Using this code:
function wfu_before_file_check_handler($changable_data, $additional_data) {
$filename = wfu_basename($changable_data[‘file_path’]);
$filepath = wfu_basedir($changable_data[‘file_path’]);
$changable_data[‘file_path’] = $filepath.’-‘.$changable_data[‘user_data’][0][‘value’];
return $changable_data;
}The uploader only have one user data input
Forum: Plugins
In reply to: [Wordpress File Upload] Run script on completed uploadThanks a lot – works great ??
Reading trough the different filters, and wondering if it would be possible to rename the file using the user data field from the $additional_data ?
All the best
Forum: Plugins
In reply to: [Wordpress File Upload] UID/UUIDHi Nicolas
No problem ?? Well the files do not have the same name. They are user defined and based on the files name.
What wound be nice is if it could be implimented in the prestart check. So that it just gives it a new name right before upload.
Another thing – would it be possible to parse the file through another js function before upload?
I use the seen.js lib on the site that have a obj parser to generate faces etc. What would be really nice is to run the uploads through the parser and save both the seen file and the original file. But this might be a something for another thread ??All the best
Forum: Plugins
In reply to: [Wordpress File Upload] UID/UUIDHi
No they get the name of the file and, currently, they are then renamed by a filerenamer plugin to append the current date.
But what I was thinking was:
User uploads file named “something”.
There are 16 files already in the upload folder.
File is renamed to “17-something“Forum: Plugins
In reply to: [Wordpress File Upload] Additional Data Fields validationHi Nikolas
Okay got it fixed ??
Turned out that it was just because the fid was set to 1 and the userinput element was 0
From there I just implemented the RedExp and if it was not a match, it alerts (could be done more elegant, but it works) and returns false. Thanks for all the help !
For anyone in the future here is the working script:
if(window.addEventListener) { window.addEventListener(“load”, wfu_check_userdata, false); }
else if(window.attachEvent) { window.attachEvent(“onload”, wfu_check_userdata); }
else { window[“onload”] = wfu_check_userdata; }function wfu_check_userdata() {
Code_Initializators[Code_Initializators.length] = function(sid) {
var Custom_Code_Objects = {};
Custom_Code_Objects.pre_start_check = function (attr) {
if (!attr) return attr;
regExp = /^\d{1,3}.\d{1,20},\d{1,3}.\d{1,20}/;
var sid = this.sid;
var fid = 0;
var WFU = GlobalData.WFU[sid];
var props = WFU.userdata.props[fid];
var result = true;
//get and check field value
var value = WFU.userdata.getValue(props);
var match = regExp.test(value)
console.log(value)
if (match) {
return result;
}
else {
alert(‘Please enter valid coordinates’)
return false;}
}
return Custom_Code_Objects;
}
wfu_Load_Code_Connectors(1);
}Forum: Plugins
In reply to: [Wordpress File Upload] Additional Data Fields validationHi
Sure the url is:
https://wi-form.com/uploader/
and the pwd isNickolas
The uploader only takes .obj
And I made a script that alerts if the user input doesn’t match
"/^\d{1,3}.\d{1,20},\d{1,3}.\d{1,20}/"
formatting, but as of right now the user can still upload even though the input doesn’t match.My script is:
" var input = document.getElementsByClassName("file_userdata_message") var userinput = document.getElementById("hiddeninput_1_userdata_0") input[0].addEventListener("blur", function() { userinputNow = userinput.value regExp = /^\d{1,3}.\d{1,20},\d{1,3}.\d{1,20}/; var match = regExp.test(userinputNow); if (match){ return } else if (userinputNow == 0){ return } else{ alert('Please enter valid coordinates') } }); "
- This reply was modified 4 years, 11 months ago by Jan Dembowski. Reason: Formatting
Forum: Plugins
In reply to: [Wordpress File Upload] Additional Data Fields validationAnd just saw that without any changes to the code you just send, it gives:
TypeError: props is undefinedForum: Plugins
In reply to: [Wordpress File Upload] Additional Data Fields validationHi Nickolas
Looks great and a lot more thought through than what I hacked out ??
But I’m having some difficulties understanding where I can setup the parameters for the validation. Do I need to set the props value ?
I have this RedExp that I want it to correspond to:
/^\d{1,3}.\d{1,20},\d{1,3}.\d{1,20}/Thanks for all you help !
Forum: Plugins
In reply to: [Wordpress File Upload] Additional Data Fields validationOkay I got it fixed with some javascript and simple RedExp.
Forum: Plugins
In reply to: [Wordpress File Upload] Additional Data Fields validationHi Nikolas
I have a very limited knowledge of javascript, but I do have programming experience. So if you point me in the right direction maybe I can solve it on my own
Thanks!