Upload files updated on CodeIgniter - codeigniter-3

happy new year everyone.
I'm a little confused in the process of the updated data. This is my controller in codeigniter
function Ubah($id_pengetahuan) {
$data['page_title'] = 'Ubah Pengetahuan';
$ses_id = $this->session->id_pengguna;
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="alert alert-warning"><strong><i class="fa fa-bullhorn" aria-hidden="true"></i> PESAN : </strong>', '</div>');
$error_msg = array('required' => '%s yang Anda masukkan belum lengkap.');
$this->form_validation->set_rules('judul', 'Judul', 'required', $error_msg);
$this->form_validation->set_rules('konten', 'Konten', 'required', $error_msg);
if ($id_pengetahuan) {
$post = $this->mod_pengetahuan->getPengetahuan_id($id_pengetahuan);
$data['id_pengetahuan'] = $id_pengetahuan;
$data['id_pengguna'] = $ses_id;
$data['judul'] = $post->judul;
$data['konten'] = $post->konten;
$data['tanggal'] = $post->tanggal;
$data['url'] = $post->tanggal;
$data['kategori'] = $post->kategori;
$data['bagikan'] = $post->bagikan;
$data['status'] = $post->status;
}
if ($this->form_validation->run() == FALSE) {
$this->view('pengetahuan_edit', $data);
}
else {
$config['upload_path'] = './assets/img/profil/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '5000'; //kilobyte
$this->upload->initialize($config);
if ( !$this->upload->do_upload('url')){
$this->session->set_flashdata('save_gagal', 'Tipe File yang Anda Masukkan tidak sesuai.');
$this->view('pengetahuan_edit', $data);
}
else{
$save['id_pengetahuan'] = $id_pengetahuan;
$save['id_pengguna'] = $ses_id;
$save['judul'] = $this->input->post('judul');
$save['konten'] = $this->input->post('konten');
$save['tanggal'] = date('Y-m-d');
$save['url'] = $this->upload->data('file_name');
$save['kategori'] = $this->input->post('kategori');
$save['bagikan'] = $this->input->post('bagikan');
$save['status'] = '1';
$post = $this->mod_pengetahuan->savePengetahuan($save);
$this->session->set_flashdata('save_succes', 'Pengguna baru berhasil ditambahkan.');
redirect('pengetahuan');
}
}
}
I want when the user makes changes to the data, users are not required to upload files. but when users upload files then processes the code below will run
if ( !$this->upload->do_upload('url')){
$this->session->set_flashdata('save_gagal', 'Tipe File yang Anda Masukkan tidak sesuai.');
$this->view('pengetahuan_edit', $data);
}
Please help me master. thank you

Try like this...
function Ubah($id_pengetahuan) {
$data['page_title'] = 'Ubah Pengetahuan';
$ses_id = $this->session->id_pengguna;
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="alert alert-warning"><strong><i class="fa fa-bullhorn" aria-hidden="true"></i> PESAN : </strong>', '</div>');
$error_msg = array('required' => '%s yang Anda masukkan belum lengkap.');
$this->form_validation->set_rules('judul', 'Judul', 'required', $error_msg);
$this->form_validation->set_rules('konten', 'Konten', 'required', $error_msg);
if ($id_pengetahuan) {
$post = $this->mod_pengetahuan->getPengetahuan_id($id_pengetahuan);
$data['id_pengetahuan'] = $id_pengetahuan;
$data['id_pengguna'] = $ses_id;
$data['judul'] = $post->judul;
$data['konten'] = $post->konten;
$data['tanggal'] = $post->tanggal;
$data['url'] = $post->tanggal;
$data['kategori'] = $post->kategori;
$data['bagikan'] = $post->bagikan;
$data['status'] = $post->status;
}
if ($this->form_validation->run() == FALSE) {
$this->view('pengetahuan_edit', $data);
}
else {
$config['upload_path'] = './assets/img/profil/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '5000'; //kilobyte
$this->load->library('upload', $config);
if ( !$this->upload->do_upload('url')){
$this->session->set_flashdata('save_gagal', 'Tipe File yang Anda Masukkan tidak sesuai.');
$this->view('pengetahuan_edit', $data);
}
else{
$save['id_pengetahuan'] = $id_pengetahuan;
$save['id_pengguna'] = $ses_id;
$save['judul'] = $this->input->post('judul');
$save['konten'] = $this->input->post('konten');
$save['tanggal'] = date('Y-m-d');
$save['url'] = $this->upload->data('file_name');
$save['kategori'] = $this->input->post('kategori');
$save['bagikan'] = $this->input->post('bagikan');
$save['status'] = '1';
$post = $this->mod_pengetahuan->savePengetahuan($save);
$this->session->set_flashdata('save_succes', 'Pengguna baru berhasil ditambahkan.');
redirect('pengetahuan');
}
}
}

Related

Woocommerce Custom Place Order API not working cart empty

public function RetriveCart($request){
global $woocommerce;
$woocommerce->frontend_includes();
$user_id = $request['user_id'];
wp_set_current_user( $user_id );
add_action('woocommerce_cart_calculate_fees', array($this,'woo_cart_fee_update'));
$woocommerce->session = new WC_Session_Handler();
$woocommerce->session->init();
$woocommerce->customer = new WC_Customer( get_current_user_id(), true );
$woocommerce->cart = new WC_Cart();
$items = $woocommerce->cart->get_cart();
if(empty($items)){
$response['status'] = 0;
$response['message'] = __("Cart is empty", self::domainText);
$response['data'] = new stdClass();
return new WP_REST_Response($response, 200);
}
foreach($items as $item => $values) {
$_product = wc_get_product( $values['product_id']);
$cart[] = array('key'=>$item,
'product_id'=>$values['product_id'],
'title'=>$_product->get_title(),
'quantity'=>$values['quantity'],
'price'=>$_product->get_price(),
'subtotal'=> strval(($_product->get_price()+$addons_price) * $values['quantity']),
'currency_symbol'=>get_woocommerce_currency_symbol(),
);
}
WC()->cart->calculate_totals();
$shipping = $woocommerce->cart->fee_total;
$cart_summary = array('sub_total'=>$woocommerce->cart->subtotal,
'shipping_amount'=>$shipping,
'order_type'=>$order_type,
'is_deliverable'=>$is_deliverable,
'discount_amount'=>$woocommerce->cart->get_cart_discount_total(),
'tax_amount'=>$woocommerce->cart->tax_total,
'total_amount'=>$woocommerce->cart->total,
'currency_symbol'=>get_woocommerce_currency_symbol(),
);
$output['cart_summary'] = $cart_summary;
$output['items'] = $cart;
$response['status'] = 1;
$response['message'] = __("Cart Items found", self::domainText);
$response['data'] = $output;
return new WP_REST_Response($response, 200);
}
public function newOrder($request){
global $wpdb,$woocommerce;
$woocommerce->frontend_includes();
$orderRequest = $request['order'];
$user_id = $orderRequest['user_id'];
wp_set_current_user( $user_id );
$woocommerce->session = new WC_Session_Handler();
$woocommerce->session->init();
$woocommerce->customer = new WC_Customer( get_current_user_id(), true );
$woocommerce->cart = new WC_Cart();
if ($woocommerce->cart->get_cart_contents_count() == 0) {
$response['status'] = 0;
$response['message'] = __('Cart is empty', self::domainText);
$response['data'] = new stdClass();
return new WP_REST_Response($response, 200);
}
$cart = $woocommerce->cart->get_cart();
$order = wc_create_order(array('customer_id' => get_current_user_id()));
$order_id = $order->id;
foreach($cart as $item => $values) {
$product = wc_get_product($values['product_id']);
$quantity = (int)$values['quantity'];
if(wc_prices_include_tax()){
$product_price = wc_get_price_including_tax($product);
}else{
$product_price = wc_get_price_excluding_tax($product);
}
$variationsArray = array();
$order->add_product($product, $quantity, $variationsArray);
}
$order->set_address( $orderRequest['billing_address'], 'billing' );
$order->set_address( $orderRequest['shipping_address'], 'shipping' );
$order->set_payment_method($orderRequest['payment_method']['id']);
$get_fees = $woocommerce->cart->get_fees();
foreach($get_fees as $fee_data){
$item_fee = new WC_Order_Item_Fee();
$item_fee->set_name($fee_data->name);
$item_fee->set_amount($fee_data->amount);
$item_fee->set_tax_class( '' );
$item_fee->set_tax_status( 'none' );
$item_fee->set_total($fee_data->total);
$item_fee->save();
$order->add_item($item_fee);
}
if(!empty($coupon)){
$order->apply_coupon($coupon[0]);
}
$order->update_status('created');
$order->calculate_totals();
$woocommerce->cart->empty_cart();
$customer_id = $order->get_user_id();
$response['status'] = 1;
$response['message'] = __("Order $order_id is successfully placed", self::domainText);
$response['order_id'] = $order_id;
return new WP_REST_Response($response, 200);
}
In RetriveCart() all datas are there when I try place order. Its give me an empty cart and fees not added.

Update controller method not rendering json data in Laravel

I have a simple form with some text inputs and uploading photos with that form. Store method working very well but I'm doing something wrong in update method.
This is my store method which works fine:
public function store(Request $request)
{
dd($request);
$post = new Post;
$post->title = $request->title;
$post->user_id = $request->user()->id;
$post->who = $request->who;
$post->when = $request->when;
$post->where = $request->where;
$post->body_text = $request->body;
$post->embed = $request->embed;
$post->status = "4";
$post->tags = $request->tags;
$post->slug = "asdasd";
$post->ip = request()->ip();
if($request->hasfile('photo'))
{
foreach($request->file('photo') as $image)
{
$name= time()."".$this->photo_san($image->getClientOriginalName());
$image->move(public_path().'/uploads/', $name);
$data[] = $name;
}
$post->photo = json_encode($data);
}
$post->save();
$post->slug = $post->id."-".$this->make_slug($request->title);
$post->save();
Session::flash('success', 'Well done.');
return redirect()->route('archive');
}
And this is my update method which saves everything but photos:
public function update(Request $request, $id)
{
if(Auth::user()->role == 3 || Auth::user()->id == Post::find($id)->user_id){
$post = Post::find($id);
$post->title = $request->title;
$post->user_id = $request->user()->id;
$post->who = $request->who;
$post->when = $request->when;
$post->where = $request->where;
$post->body_text = $request->body;
$post->embed = $request->embed;
$post->status = "4";
$post->tags = $request->tags;
$post->slug = $id."-".$this->make_slug($request->title);
$post->ip = request()->ip();
if($request->hasFile('photo'))
{
foreach($request->file('photo') as $image)
{
$name= time()."-edit-".$this->photo_san($image->getClientOriginalName());
$image->move(public_path().'/uploads/', $name);
$data[] = $name;
}
$post->photo = json_encode($data);
}
$post->save();
Session::flash('success', 'Well done.');
return redirect()->route('new');
}
else
Session::flash('error', 'Shame on you :( ');
return redirect()->route('new');
}
When I'm updating any post, everything updating but photos and I don't have any idea what's wrong.
I don't know if it differs but I'm using Laravel 5,8

EnvelopeID Changed after correction?

I have 2 signature document and the first signer already signed. The document is still in process. So I went to correct the second signer. I realised the envelopeID changed after the correction.
What will it happen to the old envelope? Voided?
function getDocuments($pdfbytes) {
$documents = array();
$id = 1;
$d = new Document();
$d->PDFBytes = $pdfbytes;
$d->Name = "Demo Document";
$d->ID = $id++;;
$d->FileExtension = "pdf";
array_push($documents, $d);
return $documents;
}
function buildEnvelope($pdfbytes) {
$envelope = new Envelope();
$envelope->Subject = $_SESSION["Taskmaster"];
$envelope->EmailBlurb = "Please Sign by logining ";
$envelope->AccountId = $_SESSION["AccountID"];
$envelope->Recipients = constructRecipients();
$envelope->Tabs = addTabs(count($envelope->Recipients));
$envelope = processOptions($envelope);
$envelope->Documents = getDocuments($pdfbytes);
return $envelope;
}
function constructRecipients() {
$recipients = array();
$r = new Recipient();
$r->UserName =$_SESSION["Secretaryname"];
$r->Email = $_SESSION["Secretaryemail"];
$r->RequireIDLookup = false;
$r->ID = 1;
$r->Type = RecipientTypeCode::Signer;
$r->RoutingOrder = "2";
// if(!isset($_POST['RecipientInviteToggle'][$i])){
$r->CaptiveInfo = new RecipientCaptiveInfo();
$r->CaptiveInfo->ClientUserId = 2;
$r->CaptiveInfo->embeddedRecipientStartURL=SIGN_AT_DOCUSIGN;
// }
array_push($recipients, $r);
if(empty($recipients)){
$_SESSION["errorMessage"] = "You must include at least 1 Recipient";
//header("Location: error.php");
exit;
}
return $recipients;
}
function sendNow($envelope) {
$api = getAPI();
$csParams = new CreateAndSendEnvelope();
$csParams->Envelope = $envelope;
//print_r($csParams);
try {
$status = $api->CreateAndSendEnvelope($csParams)->CreateAndSendEnvelopeResult;
//echo "Result for Create and Send <br>";
//print_r($status);
if ($status->Status == EnvelopeStatusCode::Sent) {
addEnvelopeID($status->EnvelopeID);
$correct = new Correction;
$correct->EnvelopeID = $status->EnvelopeID;
$correct->RecipientCorrections = addRecipientCorrection();
$correctparams = new CorrectAndResendEnvelope();
$correctparams->Correction = $correct;
//print_r($correctparams);
//Send
$response = $api->CorrectAndResendEnvelope($correctparams);
//print_r($response);
//exit;
$_SESSION["EnvelopeID"]=null;
$_SESSION["Direct"]="Yes";
header("Location: getstatusanddocs.php?envelopid=" . $status->EnvelopeID .
"&accountID=" . $envelope->AccountId . "&source=Document");
}
} catch (SoapFault $e) {
$_SESSION["errorMessage"] = $e;
header("Location: error.php");
}
}
function addRecipientCorrection(){
$correction = new RecipientCorrection();
$correction->PreviousUserName = "xxxxxx";
$correction->PreviousEmail = "xxxxxxx";
$correction->PreviousSignerName = $correction->PreviousUserName;
$correction->PreviousRoutingOrder = "2";
$correction->CorrectedUserName = $_SESSION["Secretaryname"];
$correction->CorrectedEmail = $_SESSION["Secretaryemail"];
$correction->CorrectedSignerName = $correction->CorrectedUserName;
return $correction;
}
//========================================================================
// Main
//========================================================================
loginCheck();
if($_SESSION["Taskmaster"]=="xxxxx"){
$api = getAPI();
$RequestPDFParam = new RequestPDF();
$RequestPDFParam->EnvelopeID = $_SESSION["EnvelopeID"];
$result = $api->RequestPDF($RequestPDFParam);
$envPDF = $result->RequestPDFResult;
//file_put_contents("./Cert/".$_SESSION["EnvelopeID"].".pdf", $envPDF->PDFBytes);
//echo "Stop here";
//exit;
$envelope = buildEnvelope($envPDF->PDFBytes);
sendNow($envelope);
}else{
echo "You have no power";
}
EnvelopeId does not change after correction. The envelopeID never changes. New envelopes can be created, but the original GUID that was used will keep living in the system.

Webmaster Tool Api Crawl Optimize

By using webmaster tool API to parse data from google. The speed of downloading is very slow, Is there any way to optimize, Or use another method. It can take more than hour depending on the data.
Regards.
const HOST = "https://www.google.com";
const SERVICEURI = "/webmasters/tools/";
public function __construct()
{
$this->_auth = $this->_loggedIn = $this->_domain = false;
$this->_data = array();
}
public function getArray($domain)
{
if ($this->_validateDomain($domain)) {
if ($this->_prepareData()) {
return $this->_data;
} else {
throw new Exception('Error receiving crawl issues for ' . $domain);
}
} else {
throw new Exception('The given domain is not connected to your Webmastertools account!');
exit;
}
}
public function getCsv($domain, $localPath = false)
{
if ($this->_validateDomain($domain)) {
if ($this->_prepareData()) {
if (!$localPath) {
$this->_HttpHeaderCSV();
$this->_outputCSV();
} else {
$this->_outputCSV($localPath);
}
} else {
throw new Exception('Error receiving crawl issues for ' . $domain);
}
} else {
throw new Exception('The given domain is not connected to your Webmastertools account!');
exit;
}
}
public function getSites()
{
if ($this->_loggedIn) {
$feed = $this->_getData('feeds/sites/');
if ($feed) {
$doc = new DOMDocument();
$doc->loadXML($feed);
$sites = array();
foreach ($doc->getElementsByTagName('entry') as $node) {
array_push($sites, $node->getElementsByTagName('title')->item(0)->nodeValue);
}
return (0 < sizeof($sites)) ? $sites : false;
} else {
return false;
}
} else {
return false;
}
}
public function login($mail, $pass)
{
$postRequest = array(
'accountType' => 'HOSTED_OR_GOOGLE',
'Email' => $mail,
'Passwd' => $pass,
'service' => "sitemaps",
'source' => "Google-WMTdownloadscript-0.11-php"
);
// Before PHP version 5.2.0 and when the first char of $pass is an # symbol,
// send data in CURLOPT_POSTFIELDS as urlencoded string.
if ('#' === (string) $pass[0] || version_compare(PHP_VERSION, '5.2.0') < 0) {
$postRequest = http_build_query($postRequest);
}
$ch = curl_init(self::HOST . '/accounts/ClientLogin');
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $postRequest,
));
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if (200 != $info['http_code']) {
throw new Exception('Login failed!');
exit;
} else {
#preg_match('/Auth=(.*)/', $output, $match);
if (isset($match[1])) {
$this->_auth = $match[1];
$this->_loggedIn = true;
return true;
} else {
throw new Exception('Login failed!');
exit;
}
}
}
private function _prepareData()
{
if ($this->_loggedIn) {
$currentIndex = 1;
$maxResults = 100;
$encUri = urlencode($this->_domain);
/*
* Get the total result count / result page count
*/
$feed = $this->_getData("feeds/{$encUri}/crawlissues?start-index=1&max-results=1");
if (!$feed) {
return false;
}
$doc = new DOMDocument();
$doc->loadXML($feed);
$totalResults = (int) $doc->getElementsByTagNameNS('http://a9.com/-/spec/opensearch/1.1/', 'totalResults')->item(0)->nodeValue;
$resultPages = (0 != $totalResults) ? ceil($totalResults / $maxResults) : false;
unset($feed, $doc);
if (!$resultPages) {
return false;
}
/*
* Paginate over issue feeds
*/
else {
// Csv data headline
$this->_data = Array(
Array(
'Issue Id',
'Crawl type',
'Issue type',
'Detail',
'URL',
'Date detected',
'Last detected'
)
);
while ($currentIndex <= $resultPages) {
$startIndex = ($maxResults * ($currentIndex - 1)) + 1;
$feed = $this->_getData("feeds/{$encUri}/crawlissues?start-index={$startIndex}&max-results={$maxResults}");
$doc = new DOMDocument();
$doc->loadXML($feed);
foreach ($doc->getElementsByTagName('entry') as $node) {
$issueId = str_replace(self::HOST . self::SERVICEURI . "feeds/{$encUri}/crawlissues/", '', $node->getElementsByTagName('id')->item(0)->nodeValue);
$crawlType = $node->getElementsByTagNameNS('http://schemas.google.com/webmasters/tools/2007', 'crawl-type')->item(0)->nodeValue;
$issueType = $node->getElementsByTagNameNS('http://schemas.google.com/webmasters/tools/2007', 'issue-type')->item(0)->nodeValue;
$detail = $node->getElementsByTagNameNS('http://schemas.google.com/webmasters/tools/2007', 'detail')->item(0)->nodeValue;
$url = $node->getElementsByTagNameNS('http://schemas.google.com/webmasters/tools/2007', 'url')->item(0)->nodeValue;
$dateDetected = date('d/m/Y', strtotime($node->getElementsByTagNameNS('http://schemas.google.com/webmasters/tools/2007', 'date-detected')->item(0)->nodeValue));
$updated = date('d/m/Y', strtotime($node->getElementsByTagName('updated')->item(0)->nodeValue));
// add issue data to results array
array_push($this->_data, Array(
$issueId,
$crawlType,
$issueType,
$detail,
$url,
$dateDetected,
$updated
));
}
unset($feed, $doc);
$currentIndex++;
}
return true;
}
} else {
return false;
}
}
private function _getData($url)
{
if ($this->_loggedIn) {
$header = array(
'Authorization: GoogleLogin auth=' . $this->_auth,
'GData-Version: 2'
);
$ch = curl_init(self::HOST . self::SERVICEURI . $url);
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_ENCODING => 1,
CURLOPT_HTTPHEADER => $header
));
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
return (200 != $info['http_code']) ? false : $result;
} else {
return false;
}
}
private function _HttpHeaderCSV()
{
header('Content-type: text/csv; charset=utf-8');
header('Content-disposition: attachment; filename=gwt-crawlerrors-' . $this->_getFilename());
header('Pragma: no-cache');
header('Expires: 0');
}
private function _outputCSV($localPath = false)
{
$outstream = !$localPath ? 'php://output' : $localPath . DIRECTORY_SEPARATOR . $this->_getFilename();
$outstream = fopen($outstream, "w");
if (!function_exists('__outputCSV')) {
function __outputCSV(&$vals, $key, $filehandler)
{
fputcsv($filehandler, $vals); // add parameters if you want
}
}
array_walk($this->_data, "__outputCSV", $outstream);
fclose($outstream);
}
private function _getFilename()
{
return 'gwt-crawlerrors-' . parse_url($this->_domain, PHP_URL_HOST) . '-' . date('Ymd-His') . '.csv';
}
private function _validateDomain($domain)
{
if (!filter_var($domain, FILTER_VALIDATE_URL)) {
return false;
}
$sites = $this->getSites();
if (!$sites) {
return false;
}
foreach ($sites as $url) {
if (parse_url($domain, PHP_URL_HOST) == parse_url($url, PHP_URL_HOST)) {
$this->_domain = $domain;
return true;
}
}
return false;
}
The url from Google is in error Google has added a false extension look carefully and you will see it.
Google Crap!
Your site is probably fine.

How to get my zend script picture filename into a hidden field

OK, I am stumped here. I'm using a Zend script that helps me to upload pictures. It works great, but I am trying to capture the pictures name into a hidden field for a form. I'd like to note that the name changes, so I'd need to get whichever it ends up being put into the hidden field. Here is the Zend script:
<?php
if (isset($_POST['upload'])) {
require_once('scripts/library.php');
try {
$destination = 'xxxxxxxx';
$uploader = new Zend_File_Transfer_Adapter_Http();
$uploader->setDestination($destination);
$filename = $uploader->getFileName(NULL, FALSE);
$uploader->addValidator('Size', FALSE, '90kB');
$uploader->addValidator('ImageSize', FALSE, array('minheight' => 100, 'minwidth' => 100));
if (!$uploader->isValid()) {
$messages = $uploader->getMessages();
} else {
$no_spaces = str_replace(' ', '_', $filename, $renamed);
$uploader->addValidator('Extension', FALSE, 'gif, png, jpg');
$recognized = FALSE;
if ($uploader->isValid()) {
$recognized = TRUE;
} else {
$mime = $uploader->getMimeType();
$acceptable = array('jpg' => 'image/jpeg',
'png' => 'image/png',
'gif' => 'image/gif');
$key = array_search($mime, $acceptable);
if (!$key) {
$messages[] = 'Unrecognized image type';
} else {
$no_spaces = "$no_spaces.$key";
$recognized = TRUE;
$renamed = TRUE;
}
}
$uploader->clearValidators();
if ($recognized) {
$existing = scandir($destination);
if (in_array($no_spaces, $existing)) {
$dot = strrpos($no_spaces, '.');
$base = substr($no_spaces, 0, $dot);
$extension = substr($no_spaces, $dot);
$i = 1;
do {
$no_spaces = $base . '_' . $i++ . $extension;
} while (in_array($no_spaces, $existing));
$renamed = TRUE;
}
$uploader->addFilter('Rename', array('target' => $no_spaces));
$success = $uploader->receive();
if (!$success) {
$messages = $uploader->getMessages();
} else {
$uploaded = "$filename uploaded successfully";
$pic = $filename;
if ($renamed) {
$uploaded .= " and renamed $no_spaces";
}
$messages[] = "$uploaded";
}
}
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
Here I am trying to make the $pic variable not to throw an error for now (on the form page)
if (isset($_POST['upload'])) { } else { $pic = "unknown";}
The $pic variable is what I was trying to have the filename from the zend script copied into. Any feedback is greaaaatly appreciated :)