473,800 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Image problem with $_FILES and $_POST

Hello again.
I have a form for posting news articles.

Form one is the "register" form.
Then I go to the preview form were I can select edit or accept

If I select edit, I got the "edit form" and if I select accept, I
receive a message that say:

The news article "headline" are posted into the database.

When I use the file field and browse to "my photos", select an image
and post it. I can see it in the priview form/page and can also show
it in the article.

But if I select the "edit" button I can't see the image.
I am using <input type="hidden" name="article_p hoto"
value="$article _foto"field to preserve the value of the field:
<input type="file" name="article_p hoto">

Well. I discover that if I not have anything in the field <input
type="file" name="article_p hoto"...
but still have the image.jpg in the hidden field. It use the
$_POST["article_ph oto"] insted of
$_FILES["article_ph oto"];

So I was thinking that this below should do the trick:

if(!isset($_FIL ES["article_ph oto"])){
$article_photo = $_POST["article_ph oto"];
} else {
$article_photo = $_FILES["article_ph oto"];
}

But still the image are not avaible in the edit or preview pages in
the variable $article_photo
BUT if I use the file field and browse, select an image and post it.
Then it show up in those pages.

How can I fix this? Is it better to use setcookie("arti cle_photo",
$_POST['article_photo'] time()+30);

Thanks for all advice. (and sorry my weak english)

Karl
Dec 29 '07 #1
5 2582
Karl wrote:
Hello again.
I have a form for posting news articles.

Form one is the "register" form.
Then I go to the preview form were I can select edit or accept

If I select edit, I got the "edit form" and if I select accept, I
receive a message that say:

The news article "headline" are posted into the database.

When I use the file field and browse to "my photos", select an image
and post it. I can see it in the priview form/page and can also show
it in the article.

But if I select the "edit" button I can't see the image.
I am using <input type="hidden" name="article_p hoto"
value="$article _foto"field to preserve the value of the field:
<input type="file" name="article_p hoto">

Well. I discover that if I not have anything in the field <input
type="file" name="article_p hoto"...
but still have the image.jpg in the hidden field. It use the
$_POST["article_ph oto"] insted of
$_FILES["article_ph oto"];

So I was thinking that this below should do the trick:

if(!isset($_FIL ES["article_ph oto"])){
$article_photo = $_POST["article_ph oto"];
} else {
$article_photo = $_FILES["article_ph oto"];
}

But still the image are not avaible in the edit or preview pages in
the variable $article_photo
BUT if I use the file field and browse, select an image and post it.
Then it show up in those pages.

How can I fix this? Is it better to use setcookie("arti cle_photo",
$_POST['article_photo'] time()+30);

Thanks for all advice. (and sorry my weak english)

Karl
Do you have the image file name in a <img...tag?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Dec 29 '07 #2
On 29 Des, 15:54, Jerry Stuckle <jstuck...@attg lobal.netwrote:
Karl wrote:
Hello again.
I have a form for posting news articles.
Form one is the "register" form.
Then I go to the preview form were I can select edit or accept
If I select edit, I got the "edit form" and if I select accept, I
receive a message that say:
The news article "headline" are posted into the database.
When I use the file field and browse to "my photos", select an image
and post it. I can see it in the priview form/page and can also show
it in the article.
But if I select the "edit" button I can't see the image.
I am using <input type="hidden" name="article_p hoto"
value="$article _foto"field to preserve the value of the field:
<input type="file" name="article_p hoto">
Well. I discover that if I not have anything in the field <input
type="file" name="article_p hoto"...
but still have the image.jpg in the hidden field. It use the
$_POST["article_ph oto"] insted of
$_FILES["article_ph oto"];
So I was thinking that this below should do the trick:
if(!isset($_FIL ES["article_ph oto"])){
$article_photo = $_POST["article_ph oto"];
} else {
$article_photo = $_FILES["article_ph oto"];
}
But still the image are not avaible in the edit or preview pages in
the variable $article_photo
BUT if I use the file field and browse, select an image and post it.
Then it show up in those pages.
How can I fix this? Is it better to use setcookie("arti cle_photo",
$_POST['article_photo'] time()+30);
Thanks for all advice. (and sorry my weak english)
Karl

Do you have the image file name in a <img...tag?
Yes, I have.

And it works if I use the <input type="file" name="article_p hoto">
field.
$article_photo = $_FILES["article_ph oto"]; make it work.
But when I have the image.jpg registred in a <input type="hidden".. .
field, it does not work.

I think that this hidden field use the $_POST["article_ph oto"]
instead of $_FILES["article_ph oto"] because if i "comment out" the
$_FILES... line and insted use $_POST["article_ph oto"] I can find it..
But then the file field not work..

Karl
Dec 29 '07 #3
Karl wrote:
On 29 Des, 15:54, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>Karl wrote:
>>Hello again.
I have a form for posting news articles.
Form one is the "register" form.
Then I go to the preview form were I can select edit or accept
If I select edit, I got the "edit form" and if I select accept, I
receive a message that say:
The news article "headline" are posted into the database.
When I use the file field and browse to "my photos", select an image
and post it. I can see it in the priview form/page and can also show
it in the article.
But if I select the "edit" button I can't see the image.
I am using <input type="hidden" name="article_p hoto"
value="$artic le_foto"field to preserve the value of the field:
<input type="file" name="article_p hoto">
Well. I discover that if I not have anything in the field <input
type="file" name="article_p hoto"...
but still have the image.jpg in the hidden field. It use the
$_POST["article_ph oto"] insted of
$_FILES["article_ph oto"];
So I was thinking that this below should do the trick:
if(!isset($_F ILES["article_ph oto"])){
$article_photo = $_POST["article_ph oto"];
} else {
$article_photo = $_FILES["article_ph oto"];
}
But still the image are not avaible in the edit or preview pages in
the variable $article_photo
BUT if I use the file field and browse, select an image and post it.
Then it show up in those pages.
How can I fix this? Is it better to use setcookie("arti cle_photo",
$_POST['article_photo'] time()+30);
Thanks for all advice. (and sorry my weak english)
Karl
Do you have the image file name in a <img...tag?

Yes, I have.

And it works if I use the <input type="file" name="article_p hoto">
field.
$article_photo = $_FILES["article_ph oto"]; make it work.
But when I have the image.jpg registred in a <input type="hidden".. .
field, it does not work.

I think that this hidden field use the $_POST["article_ph oto"]
instead of $_FILES["article_ph oto"] because if i "comment out" the
$_FILES... line and insted use $_POST["article_ph oto"] I can find it..
But then the file field not work..

Karl
OK, did you write this yourself? Or is this someone else's script?

If the latter, that's who you should be asking.

And <input type="file"...a nd <input type="hidden".. .have two
entirely different uses.

And sure - if you comment out the $_FILES line, there is no way for the
file field will work.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Dec 29 '07 #4
On 29 Des, 19:51, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>
OK, did you write this yourself? Or is this someone else's script?
No it's mine :)
>
If the latter, that's who you should be asking.

And <input type="file"...a nd <input type="hidden".. .have two
entirely different uses.
Yes, I know.
And sure - if you comment out the $_FILES line, there is no way for the
file field will work.
Yes, of course. I do it just to try what would happen.

Anyway. If I select to post the image.jpg by the file field on the
"edit" page. It work.
I had hoped to find a way to "transfer" it through this different view
of forms without post it a second time.

Karl
Dec 29 '07 #5
Karl wrote:
On 29 Des, 19:51, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>OK, did you write this yourself? Or is this someone else's script?

No it's mine :)
>If the latter, that's who you should be asking.

And <input type="file"...a nd <input type="hidden".. .have two
entirely different uses.
Yes, I know.
>And sure - if you comment out the $_FILES line, there is no way for the
file field will work.

Yes, of course. I do it just to try what would happen.

Anyway. If I select to post the image.jpg by the file field on the
"edit" page. It work.
I had hoped to find a way to "transfer" it through this different view
of forms without post it a second time.

Karl
OK, this is a little more clear now.

The only way you can get data from one page to another is either via a
form field or the $_SESSION variable.

In a case like this, I'd just use the hidden field to pass the old name.
If the user uploads a new file, use it. Otherwise just use the old
file (the one passed in the hidden field).

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Dec 29 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11768
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
9
2274
by: pescott | last post by:
Hello people, I could really use your help on this one... I have script to upload image data to a database, but all that is uploaded is the decription, not the data BLOB itself. There must be something wrong with the code that fread() and fopen() the file, but what? The inclusion file below, which diplays the form: <?php print ("<table>"); print ("<tr>");
7
1716
by: pescott | last post by:
I am still struggling to get some files uploaded to a database as BLOB data. I have 5 includes which allows the user to upload 5 files, numbered accordingly. However, there are script errors. Duhh, why else would I post? Well, here goes: CODE $adres = trim (htmlspecialchars($_POST)); $verkocht = trim (htmlspecialchars($_POST)); $form_description1 = trim (htmlspecialchars($_POST));
0
1805
by: doffer | last post by:
I want to make a portfoliosystem where user can register and get their own portfolio... I've started the developer work, but I'm stuck on the image upload part... I'm experiencing some problems getting the picture resized and thumbnailed... I'm on a apache server running php 5 with 8MB php_memory. When uploading, the script works fine most times when uploading small files (below 100kb and sometimes up close to 300kb too), but when...
1
2371
by: Glenn Coyle | last post by:
Hi I am having trouble writing the file path of a image to the database,also for some reason it is not uploading the images, anyone have any ideas? the code is below: if($_POST == 'Submit') {
12
3367
by: Shawn Northrop | last post by:
Ive been searching for an image resize tutorial for a while now and found this code which worked nicely. I was unable to find the full source code but i think i pieced together the code from the tutorials correctly. My problem is when i upload an image it does not fit any case in the open_image function switch statement. when i echo $file i get 0808...tmp on my localhost server and 0808.... on my webhosting server. There is no .jpg even if...
7
2368
by: xx75vulcan | last post by:
Hi, I've got a PHP Upload Form that works great, unless that is, the image your uploading has been modified through a photo editing software. Example: if I upload the image straight from a camera or other, it uploads fine. However, If I want to rotate the image, or resize it with photoshop or simmilar, making sure to save it again as a jpg, the PHP upload won't upload the image.
2
2141
by: mac | last post by:
Hi, I'm looking for a script that will allow me to upload images to a folder and shows pagination... pls can any body help me? i hav done with the uploading, but not able to do with the pagination...here is the upload code..
1
4887
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop program,which can upload many file in folder.problem is,am unable to save my file name in to database.because i used same name for all input file type as file. i dont know get name of file.below i presented my coding for ur view.fed up with my coding..pls...
0
9695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10514
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10287
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10260
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10042
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2956
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.