好的,我有一个用于上传图像的小应用程序(使用phonegap,Jquery).我通过AJAX上传jquery处理.图像正在发送但我不确定如何在severside正确处理它.任何想法都非常欢迎!到目前为止,这是我的代码:
PHP:
<?php
////////THE PROBLEM AREA I THNK//////////
if ($_REQUEST['image']) {
// convert the image data from base64
$imgData = base64_decode($_REQUEST['image']);
// set the image paths
$file = '/uploaded_files/' . md5(date('Ymdgisu')) . '.jpg';
$url = 'http://creativetree.co/creativetreeAlpha' . $file;
// delete the image if it already exists
if (file_exists($file)) { unlink($file); }
// write the imgData to the file
$fp = fopen($file, 'w');
fwrite($fp, $imgData);
fclose($fp);
}
echo "<h1>Page is online</h1>";
echo "<p>Nothing special just a first go at phonegap! </p>"; …Run Code Online (Sandbox Code Playgroud) 我正在尝试整理一个小型的phonegap应用程序,将图像上传到协作网站.我查看了教程和API.到目前为止,我已经捕获了图像,但我仍然坚持将其送到服务器.我希望用jquery来ajax它.我的jquery似乎停止了图像捕获btn工作,当我把它取出btn工作并捕获图像.还有除了jquery之外的其他方法我可以做到这一点,或者我只是在做一个plonker并且缺少一些东西?我对phonegap很新.
$(document).ready(function() {
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50 });
}
function onFail(message) {
alert('Failed because: ' + message);
}
function onPhotoDataSuccess(imageData) {
var url = 'http://www.creativetree.co/phonegapupload.php';
var params = {image: imageData};
navigator.notification.alert('photo taken');
$.post(url, params, function(data) {
// Display the selected image on send complete
$('#image').attr('src', 'data:image/jpeg;base64,' + params['image']);
});
}
});
Run Code Online (Sandbox Code Playgroud) 我已经使用 pear 在 wamp 服务器中安装了 phpunit,目录结构如下 C:\Easy-PHP\pear\PHPUnit。
PHPUnit 运行良好,我可以从全局运行它,即 c:\phpUnit
我的问题是如何从目录内运行测试?
例如:
我有要在 c:\Users\j.bloggs\workspace\assets\project-name\classes\myClass.php 中测试的类
我在 c:\Users\j.bloggs\workspace\assets\project\tests\myClassTest.php 中有测试
如何设置使用 PHPUnit 以这种方式运行测试?我看到了关于 phpunit.xml 和 bootstrap.php 的信息,我该如何实现这些?我还没有找到任何关于这一点的明确信息。
谢谢你的帮助。