es un eshop hecho en flash, xml y php.
todo funciona perfecto pero cuando quiero subir una imagen me tira un error. tengo asignado los permisos 777 a las carpetas respectivas pero no hay caso.
el codigo es el siguiente:
Código :
// //developer : Yiannis Yeoryousis //email : [email protected] // //open product categories import flash.net.FileReference; if (_global.logedIn == true) { var selectedProduct; var myProductCategories:XML = new XML(); var productCategoriesListener:Object = new Object(); var productListListener:Object = new Object(); myProductCategories.ignoreWhite = true; myProductCategories.load("../xml/mainConstructor.xml"); myProductCategories.onLoad = function() { category.productCategories.dataProvider = this.firstChild; }; category.productCategories.addEventListener("change", productCategoriesListener); //product details productCategoriesListener.change = function(evt:Object) { //upload images var allTypes:Array = new Array(); var imageTypes:Object = new Object(); imageTypes.description = "Images (*.jpg, *.jpeg, *.gif, *.png)"; imageTypes.extension = "*.jpg; *.jpeg; *.gif; *.png"; allTypes.push(imageTypes); var allTypes2:Array = new Array(); var imageTypes2:Object = new Object(); imageTypes2.description = "Images (*.jpg, *.jpeg, *.gif, *.png)"; imageTypes2.extension = "*.jpg; *.jpeg; *.gif; *.png"; allTypes2.push(imageTypes2); var listener:Object = new Object(); var listener2:Object = new Object(); listener.onSelect = function(file:FileReference):Void { details.uploadThumbnail.onPress = function() { file.upload("../phpScripts/upload.php"); details.textArea.text = "image selected"; }; }; listener2.onSelect = function(file2:FileReference):Void { details.uploadPreview.onPress = function() { file2.upload("../phpScripts/uploadPreviewImage.php"); details.textArea2.text = "image selected"; }; }; listener.onCancel = function(file:FileReference):Void { details.textArea.text = "an error occured"; }; listener2.onCancel = function(file2:FileReference):Void { details.textArea2.text = "an error occured"; }; listener.onOpen = function(file:FileReference):Void { trace("onOpen: "+file.name); }; listener2.onOpen = function(file2:FileReference):Void { trace("onOpen: "+file.name); }; listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { loaded = Math.round((bytesLoaded/bytesTotal)*100); details.textArea.text = "loaded : "+loaded+" %"; }; listener2.onProgress = function(file2:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { loaded = Math.round((bytesLoaded/bytesTotal)*100); details.textArea2.text = "loaded : "+loaded+" %"; }; listener.onComplete = function(file:FileReference):Void { var item_obj:Object = {feature:"Image Thumbnail", details:"productImages/thumbnails/"+file.name}; details.myProduct.replaceItemAt(3, item_obj); }; listener2.onComplete = function(file2:FileReference):Void { var item_obj:Object = {feature:"Image Preview", details:"productImages/previewImages/"+file2.name}; details.myProduct.replaceItemAt(4, item_obj); }; listener.onHTTPError = function(file:FileReference):Void { details.textArea.text = "an error occured"; }; listener2.onHTTPError = function(file2:FileReference):Void { details.textArea3.text = "an error occured"; }; listener.onIOError = function(file:FileReference):Void { details.textArea.text = "an error occured"; }; listener2.onIOError = function(file2:FileReference):Void { details.textArea2.text = "an error occured"; }; listener.onSecurityError = function(file:FileReference, errorString:String):Void { details.textArea.text = "an error occured"; }; listener2.onSecurityError = function(file2:FileReference, errorString:String):Void { details.textArea2.text = "an error occured"; }; var fileRef:FileReference = new FileReference(); var fileRef2:FileReference = new FileReference(); fileRef.addListener(listener); fileRef2.addListener(listener2); details.browse_btn.onPress = function() { fileRef.browse(allTypes); }; details.browse_btn2.onPress = function() { fileRef2.browse(allTypes2); }; // selectedProductCategory = evt.target.selectedNode.attributes.data; productDetails = new Array({feature:"Product Code", details:"..."}, {feature:"Label", details:"..."}, {feature:"Model", details:"..."}, {feature:"Image Thumbnail", details:"..."}, {feature:"Image Preview", details:"..."}, {feature:"Price", details:"..."}, {feature:"Description", details:"..."}, {feature:"Extra Feature", details:"..."}); details.saveProduct.label = "Save Product"; details.newProductDetail.label = "Add Product Details"; details.myProduct.dataProvider = productDetails; details.myProduct.hScrollPolicy = "auto"; details.myProduct.resizableColumns = true; details.myProduct.getColumnAt(0).editable = true; details.myProduct.getColumnAt(0).width = 150; details.myProduct.sortableColumns = false; details.newProductDetail.onRelease = function() { var item_obj:Object = {feature:"Extra Feature", details:"..."}; details.myProduct.addItemAt(details.myProduct.length, item_obj); }; details.saveProduct.onRelease = function() { var newXmlNode:String = ""; var newXmlNodeExtraFeatures:String = ""; var newXmlNodeExtraFeaturesLabels:String = ""; for (i=0; i<7; i++) { newXmlNode += productDetails.getItemAt(i).details+"//"; } for (j=7; j<details.myProduct.length; j++) { newXmlNodeExtraFeatures += productDetails.getItemAt(j).details+"//"; } for (j=7; j<details.myProduct.length; j++) { newXmlNodeExtraFeaturesLabels += productDetails.getItemAt(j).feature+"//"; } var my_send:LoadVars = new LoadVars(); var my_load:LoadVars = new LoadVars(); //variables to send my_send.xmlFile = "../xml/"+selectedProductCategory; my_send.productDetails = newXmlNode; my_send.productExtraDetails = newXmlNodeExtraFeatures; my_send.productExtraDetailsLabels = newXmlNodeExtraFeaturesLabels; my_send.sendAndLoad("../phpScripts/newProduct.php", my_load, "POST"); my_load.onLoad = function() { gotoAndStop(2); result.txt.text = "Product inserted succesfully in database!"; }; }; }; } else { gotoAndStop(3); } stop();
se que en listener y en listener2 esta el tema que llama al php... aqui les muestro el codigo del php.
upload.php:
Código :
<?php if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) { $uploadDirectory = "../productImages/thumbnails/"; $uploadFile = $uploadDirectory . basename($_FILES['Filedata']['name']); copy($_FILES['Filedata']['tmp_name'], $uploadFile); } ?>
uploadPreviewImage.php
Código :
<?php if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) { $uploadDirectory = "../productImages/previewImages/"; $uploadFile = $uploadDirectory . basename($_FILES['Filedata']['name']); copy($_FILES['Filedata']['tmp_name'], $uploadFile); } ?>
Estoy usando en mi server php 5.2.8
a la carpeta /productImages le di permisos 777 incluso a las de adentro.
la cuestion es que me tira un erro en el primer listener y en el segundo llega al 100% y se queda colgado y no pasa nada.
aqui les dejo la URL del DEMO del sistema:
Demo del sistema, user: admin, pass: admin
[url=http://s3.envato.com/files/7570/admin.html][/url]
(justo en el demo pasa el mismo problema no carga las imagenes)
desde ya muchas gracias a todos aquellos que le hechen un vistazo a este codigo y que me puedan dar una ayuda.
Gracias.