473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can I convert a image to text code?

Ajm113
161 100+
Ok, I want allow the user to use their own background image for their home page and I want to do something like this. Where when the image is uploaded it will translate into text data and will be saved in a cookie so when ever the user comes back the image will display on the home page:

http://software.hixie.ch/utilities/cgi/data/data

Any links or code?

Thanks, Ajm.
Nov 4 '07 #1
3 5160
post
17
Ok, I want allow the user to use their own background image for their home page and I want to do something like this. Where when the image is uploaded it will translate into text data and will be saved in a cookie so when ever the user comes back the image will display on the home page:

http://software.hixie.ch/utilities/cgi/data/data

Any links or code?

Thanks, Ajm.
Here is a simple upload script that will allow certain files to be uploaded, after upload you can execute a query to the path of the image in the users information.

Page name: x.php

[php]
<?php

$target = "upload/path/insert/here/";
$target = $target . basename( $_FILES['file']['name']);

$image=($_FILES['file']['name']);

if (chk_file($image)) { $error = "Invalid Extension"; echo("<pre><center>"); echo($error); echo("</pre></center>"); exit; }

if($_POST['file'] == "") { $error = "Please upload your file."; }

if(!chk_file($image) && move_uploaded_file($_FILES['file']['tmp_name'], $target) && isset($image))
{
$error = "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded.";
//echo("<img src=\"{$target}\">");
//Insert mysql statement here
echo($error);
}
elseif (is_uploaded_file($_FILES['file']['tmp_name']) == FALSE && $_POST['file'] != "") {
$error = "Sorry, there was a problem uploading your file.";
}
?>
<?php
function chk_file($file) {
$approve = Array('1' => '.JPG', '2' => '.GIF', '3' => '.PNG');
$deny = Array('1' => '.exe', '2' => '.php');
$str = strtoupper($file);

foreach ($approve as $id=>$ext) {
if (preg_match("/$ext/i", $str)) {
$status = false;
}
}
foreach ($deny as $id=>$ext) {
if (preg_match("/$ext/i", $str)) {
$status = true;
}
}
return $status;
}
?>
[/php]
[html]
<center>
<?php echo($error); ?>
<pre>
<form action="x.php" method="POST" enctype="multipart/form-data" class="style2">
<div align="center">
File: <input type="file" name="file"><br>
<input name="Submit" type="submit" class="style1" value="Add"><br />
</div>
</form>
</pre>
</center>
[/html]
Nov 4 '07 #2
Ajm113
161 100+
I was playing around with the code and reversed the functions to uptop in your first script snipit to see if I could get rid of these errors:

I have php 4 (I think)


Notice: Undefined index: file in Path/Path

Notice: Undefined index: uploadedfile in Path/Path

Can you help me out? It's been a while since I have touched php.
Nov 4 '07 #3
post
17
I was playing around with the code and reversed the functions to uptop in your first script snipit to see if I could get rid of these errors:

I have php 4 (I think)


Notice: Undefined index: file in Path/Path

Notice: Undefined index: uploadedfile in Path/Path

Can you help me out? It's been a while since I have touched php.
What I think that is you forgot to change the variable $target to where you want to upload the files. Easier to narrow it down if you have the exact line # the error takes place on.
Nov 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Toby Mathews | last post by:
Hi, In an ASP.Net application I want to convert open create a FileStream object from a System.Drawing.Image - is this possible? I create an instance of an Image object using the FromFile method,...
0
by: Nicolas Guilhot | last post by:
Hi all ! I have a multi-page Tiff image file that I want to convert to PDF. To do so I am using iText library. The conversion is working, but the code execution is very different according to...
1
by: mevar81 | last post by:
Hello to everybody.I have a problem.I used a TypeDescriptor to retrieve a TypeConverter to convert an Image to a string.The problem is that it converts the image to the string...
3
by: dale zhang | last post by:
Hi, I am trying to read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp The article author is using PictureBox for windows...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
1
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a...
2
by: UJ | last post by:
I have need to convert a text string (with formatting) to an image. This is so that I can resize the image to different sizes and the formatting stays exactly the same regardless of the size. I...
5
by: Socrates | last post by:
I am interested in developing an online utility that will enable users to copy and past any image (or upload any image on the internet) to the online utility, which will then convert the image to...
5
by: stef | last post by:
hello I can find all kind of procedures to convert an array to a bitmap (wxPython, PIL), but I can't find the reverse, either - convert a bitmap to an array or - read a bitmap file to an...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.