I'm trying to send the file id ( this.fileProgressID ) to be stored in my database. I'm going to use it to delete files later after the upload, to display thumbnails, etc.
I don't want the info to come from a form field, but just post this.fileProgressID to $_POST['some_name']. You get the idea.
I got it to work. I am using SWFUpload v2.1.0. In my handler.js file, this is the portion of the code I changed:
function uploadStart(file) {
var itFailed = 0;
try {
/* I don't want to do any file validation or anything, I'll just update the UI and
return true to indicate that the upload should start.
It's important to update the UI here because in Linux no uploadProgress events are called. The best
we can do is say we are uploading.
*/
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setStatus("Uploading...");
progress.toggleCancel(true, this);
}
catch (ex) {}
return true;
}
The only thing I added was this.addFileParam(file.id, "param1", file.id);
The first argument file.id tells the script to add the parameter to this file. The second argument is the $_POST name. It can be anything you want. The third argument is file.id again. I want to store the file.id in my database so that I can let the user delete a file from the index page after it has been uploaded.
The file.id for the first file will be SWFUpload_0_0. The second will be SWFUpload_0_1, the third will be SWFUpload_0_2... You get the idea.
Then, on my upload.php page, I inserted $_POST[param1] into my database. If anyone has questions, feel free to ask.
Re post param
Before I start throwing out random code I need a little more info. What exactly are you trying to pass along, maybe a form fields info?
I also need help
I'm trying to send the file id ( this.fileProgressID ) to be stored in my database. I'm going to use it to delete files later after the upload, to display thumbnails, etc.
I don't want the info to come from a form field, but just post this.fileProgressID to $_POST['some_name']. You get the idea.
Solution to implementing this.addFileParam()
I got it to work. I am using SWFUpload v2.1.0. In my handler.js file, this is the portion of the code I changed:
function uploadStart(file) {var itFailed = 0;
try {
/* I don't want to do any file validation or anything, I'll just update the UI and
return true to indicate that the upload should start.
It's important to update the UI here because in Linux no uploadProgress events are called. The best
we can do is say we are uploading.
*/
// Add parameter
this.addFileParam(file.id, "param1", file.id);
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setStatus("Uploading...");
progress.toggleCancel(true, this);
}
catch (ex) {}
return true;
}
The only thing I added was
this.addFileParam(file.id, "param1", file.id);The first argument file.id tells the script to add the parameter to this file. The second argument is the $_POST name. It can be anything you want. The third argument is file.id again. I want to store the file.id in my database so that I can let the user delete a file from the index page after it has been uploaded.
The file.id for the first file will be SWFUpload_0_0. The second will be SWFUpload_0_1, the third will be SWFUpload_0_2... You get the idea.
Then, on my upload.php page, I inserted $_POST[param1] into my database. If anyone has questions, feel free to ask.